note 24688 added to function.print-r
| From: | doug dot holton at vanderbilt dot edu | Date: | Sun, 25 Aug 2002 20:41:23 +0000 |
| Subject: | note 24688 added to function.print-r | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35606@lists.php.net to get a copy of this message | ||
I combined two of the above suggestions so that I can easily call debugprint($var) anytime I want to
see a variable's value. There is an optional 2nd parameter too if you want to pass the
variable's name or any message.
function quote(&$val) {
if (is_array($val)) {
array_walk(&$val, 'quote');
return;
}
$val = htmlentities($val);
}
function debugprint($var, $msg = "Variable value") {
$isarray = is_array($var);
ob_start();
array_walk(&$var, 'quote');
print_r($var);
$output = "\n<br><font color=\"red\"><b><u>[DEBUG] ";
$output .= $msg;
$output .= ":</u> ";
if ($isarray) $output .= "<pre>";
$output .= ob_get_contents();
if ($isarray) $output .= "</pre>";
$output .= "</b></font><br>\n";
ob_end_clean();
return $output;
}
--
http://www.php.net/manual/en/function.print-r.php
http://master.php.net/manage/user-notes.php?action=edit+24688
http://master.php.net/manage/user-notes.php?action=delete+24688
http://master.php.net/manage/user-notes.php?action=reject+24688