Home > php教程 > php手册 > PHP格式化输出打印变量

PHP格式化输出打印变量

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:09:32
Original
1990 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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template