note 24688 deleted from function.print-r by didou

From: Date: Tue, 07 Sep 2004 20:21:17 +0000
Subject: note 24688 deleted from function.print-r by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76165@lists.php.net to get a copy of this message
Note Submitter: doug dot holton at vanderbilt dot edu ---- 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; }

« previous php.notes (#76165) next »