Home > php教程 > php手册 > body text

PHP格式化输出打印变量

WBOY
Release: 2016-06-06 20:09:32
Original
1900 people have browsed it

PHP 常用的输入变量函数print_r,但是输出没有换行,看起来很费力 我们可以自定义一个函数来实现变量的格式化输出,代码如下: function dump($vars, $label = '', $return = false) {if (ini_get('html_errors')) {$content = "\n";if ($label != '') {$con

PHP常用的输入变量函数print_r,但是输出没有换行,看起来很费力

我们可以自定义一个函数来实现变量的格式化输出,代码如下:

function dump($vars, $label = '', $return = false) {
if (ini_get('html_errors')) {
$content = "\n";
if ($label != '') {
$content .= "{$label} :\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n\n";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
Copy after login

Posts related to PHP格式化输出打印变量

移除Magento帐户面板里的可下载类商品

移除Magento帐户面板里的可下载类商品

四步完美解决Magento批量导入带图片的商品

四步完美解决Magento批量导入带图片的商品

Magento格式化输出调试对象的类和方法

Magento格式化输出调试对象的类和方法

Magento裁剪后的略缩图背景填充颜色的修改

Magento裁剪后的略缩图背景填充颜色的修改

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!