Home  >  Article  >  Backend Development  >  Use the dump function to add breakpoint testing to PHP_PHP tutorial

Use the dump function to add breakpoint testing to PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:03:36995browse

复制代码 代码如下:

function dump($var, $echo=true,$label=null, $strict=true)
{
    $label = ($label===null) ? '' : rtrim($label) . ' ';
    if(!$strict) {
        if (ini_get('html_errors')) {
            $output = print_r($var, true);
            $output = "
".$label.htmlspecialchars($output,ENT_QUOTES)."
";
        } else {
            $output = $label . " : " . print_r($var, true);
        }
    }else {
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        if(!extension_loaded('xdebug')) {
            $output = preg_replace("/]=>n(s+)/m", "] => ", $output);
            $output = '
'. $label. htmlspecialchars($output, ENT_QUOTES). '
';
        }
    }
    if ($echo) {
        echo($output);
        return null;
    }else
        return $output;
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327834.htmlTechArticle复制代码 代码如下: function dump($var, $echo=true,$label=null, $strict=true) { $label = ($label===null) ? '' : rtrim($label) . ' '; if(!$strict) { if (ini_get('html_errors'...
Statement:
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