php - PHP Debug Echo 的

php - PHP Debug Echo 的

我使用彩色输出,但它与网站的布局有很多“螺丝钉”,但它提供的信息最多:

define("LOG_ERROR",2);

function svar_dump_array($vInput, $iLevel = 1, $maxlevel=7) {

if (LOG_ERROR<2) return; // in cakephp the log error is set to 0 on running systems

// set this so the recursion goes max this deep

$bg[1] = "#DDDDDD";

$bg[2] = "#C4F0FF";

$bg[3] = "#00ffff";

$bg[4] = "#FFF1CA";

$bg[5] = "white";

$bg[6] = "#BDE9FF";

$bg[7] = "#aaaaaa";

$bg[8] = "yellow";

$bg[9] = "#eeeeee";

for ($i=10; $i<100; $i++) $bg[$i] = $bg[$i%9 +1];

if($iLevel == 1) $brs='

'; else $brs='';

$return = <<

{$brs}

";

} else if (is_float($vInput)) {

$return .= " ".doubleval($vInput)." ,";

} else if (is_string($vInput)) {

if(!function_exists("my_html_special_chars")){

$return .="

\"" . htmlspecialchars($vInput). "\",".(strlen($vInput)>5?"#".strlen($vInput):'')."
"; #nl2br((nbsp_replace(,

}else{

$return .="

\"" . my_html_special_chars($vInput). "\",".(strlen($vInput)>5?"#".strlen($vInput):'')."
"; #nl2br((nbsp_replace(,

}

} else if (is_bool($vInput)) {

$return .= "" . ($vInput ? "true" : "false") . " ,";

} else if (is_array($vInput) or is_object($vInput)) {

reset($vInput);

$return .= gettype($vInput).'(';

if (is_object($vInput)) {

$return .= " \"".get_class($vInput)."\" Object of ".get_parent_class($vInput);

if (get_parent_class($vInput)=="") $return.="stdClass";

$return.="";

$vInput->class_methods="\n".implode(get_class_methods($vInput),"();\n");

}

$return .= " # count=[" . count($vInput) . "] dimension=[{$iLevel}]

";

}

$return .= "

EOH;

if (is_int($vInput)) {

$return .= " ".intval($vInput)." ,

";

$return .= <<

EOH;

while (list($vKey, $vVal) = each($vInput)){

$return .= "

";

}

$return .= "

";

$return .= (is_int($vKey)) ? "" : "\"";

if(!function_exists("my_html_special_chars")) $return .= nbsp_replace(htmlspecialchars($vKey))."";

else $return .= nbsp_replace(my_html_special_chars($vKey))."";

$return .= (is_int($vKey)) ? "" : "\"";

$return .= "

=> ";

if ($iLevel>$maxlevel and is_array($vVal)) $return .= svar_dump_array("array(".sizeof($vVal)."), but Recursion Level > $maxlevel!!", ($iLevel + 1), $maxlevel);

else if ($iLevel>$maxlevel and is_object($vVal)) $return .= svar_dump_array("Object, but Recursion Level > $maxlevel!!", ($iLevel + 1), $maxlevel);

else $return .= svar_dump_array($vVal, ($iLevel + 1), $maxlevel) . "

),";

} else {

if (gettype($vInput)=="NULL") $return .="null,";

else $return .=gettype($vInput);

if (($vInput)!="") $return .= " (".($vInput).")

";

return $return;

}

function my_html_special_chars($t,$double_encode = true){

/*

* charset='ISO-8859-1' Definiert die zu verwendende Zeichenkodierung.

* Standardwert ist ISO-8859-1 in PHP Versionen vor 5.4.0 und UTF-8 in PHP 5.4.0 und neuer.

* daher brauchen wir diese funktion

*/

if(version_compare(PHP_VERSION,'5.3.0', '>=')) {

return htmlspecialchars($t,ENT_IGNORE,'ISO-8859-1',$double_encode);

} else if(version_compare(PHP_VERSION,'5.2.3', '>=')) {

return htmlspecialchars($t,ENT_COMPAT,'ISO-8859-1',$double_encode);

} else {

return htmlspecialchars($t,ENT_COMPAT,'ISO-8859-1');

}

}

function nbsp_replace($t){

return str_replace(" "," ",$t);

}

相关推荐

如何用纯按键方式关闭苹果手机?
28365365体育在线投注

如何用纯按键方式关闭苹果手机?

📅 07-14 👁️ 7524
兼职跑腿平台哪个最好?5大平台优劣势全面对比分析,新手必看!
如何记录宝宝的成长轨迹?妈妈写日记经验分享【1-3岁早教育儿知识】