php中自定义函数dump查看数组信息类似var_dump
时间:2021-03-29 09:42:44|栏目:PHP代码|点击: 次
这个很早就有了,比php自带的var_dump好用多了。
function dump($vars, $label = '', $return = false) {
if (ini_get('html_errors')) {
$content = "<pre>\n";
if ($label != '') {
$content .= "<strong>{$label} :</strong>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
复制代码 代码如下:
function dump($vars, $label = '', $return = false) {
if (ini_get('html_errors')) {
$content = "<pre>\n";
if ($label != '') {
$content .= "<strong>{$label} :</strong>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
上一篇:PHP实现基于图的深度优先遍历输出1,2,3...n的全排列功能
栏 目:PHP代码
下一篇:php写入、删除与复制文件的方法
本文标题:php中自定义函数dump查看数组信息类似var_dump
本文地址:http://www.codeinn.net/misctech/90406.html






