think\Debug::dump PHP Method

dump() public static method

浏览器友好的变量输出
public static dump ( mixed $var, boolean $echo = true, string $label = null, integer $flags = ENT_SUBSTITUTE ) : void | string
$var mixed 变量
$echo boolean 是否输出 默认为true 如果为false 则返回输出字符串
$label string 标签 默认为空
$flags integer htmlspecialchars flags
return void | string
    public static function dump($var, $echo = true, $label = null, $flags = ENT_SUBSTITUTE)
    {
        $label = null === $label ? '' : rtrim($label) . ':';
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        $output = preg_replace('/\\]\\=\\>\\n(\\s+)/m', '] => ', $output);
        if (IS_CLI) {
            $output = PHP_EOL . $label . $output . PHP_EOL;
        } else {
            if (!extension_loaded('xdebug')) {
                $output = htmlspecialchars($output, $flags);
            }
            $output = '<pre>' . $label . $output . '</pre>';
        }
        if ($echo) {
            echo $output;
            return null;
        } else {
            return $output;
        }
    }

Usage Example

Esempio n. 1
0
/**
 * 浏览器友好的变量输出
 * @param mixed $var 变量
 * @param boolean $echo 是否输出 默认为true 如果为false 则返回输出字符串
 * @param string $label 标签 默认为空
 * @return void|string
 */
function dump($var, $echo = true, $label = null)
{
    return \think\Debug::dump($var, $echo, $label);
}
All Usage Examples Of think\Debug::dump