php中自定义函数dump查看数组信息类似var_dump

 2025-01-15  阅读 433  评论 8  点赞 425

摘要:这个很早就有了,比php自带的var_dump好用多了。 复制代码 代码如下: function dump($vars, $label = '', $return = false) { if (ini_get('html_errors')) { $content = "\n"; if ($label != '') { $content .= "{$label} :\n"; } $content .= htmlspecialchars(print_r($va
这个很早就有了,比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;
}

标签:phpphp教程

评论列表:

显示更多评论

发表评论:

管理员

承接各种程序开发,外贸网站代运营,外贸网站建设等项目
  • 内容2462
  • 积分67666
  • 金币90666

Copyright © 2024 LS'Blog-保定PHP程序员老宋个人博客 Inc. 保留所有权利。 Powered by LS'blog 3.0.3

页面耗时0.0273秒, 内存占用1.94 MB, 访问数据库30次

冀ICP备19034377号