note 13860 deleted from function.print-r by aidan
| From: | aidan@php.net | Date: | Mon, 11 Oct 2004 13:05:06 +0000 |
| Subject: | note 13860 deleted from function.print-r by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78328@lists.php.net to get a copy of this message | ||
Note Submitter: hlecuanda at autologue dot com_NOSPAM
----
I've written this little function using print_r. it works very nicely. Just be sure to have a
global variable called $debug. if you set it to true, dp() will activate, if set to false, nothing
will happen. Nice when developing/debugging code with lots of arrays and objects =)!
It will print a beautified version of your call.
function dp($call,$cname) {
// call: the variable you want to print_r
// cname: the label for your debugging output
global $debug;
if ($debug) {
echo $cname.":<pre>";
if (!is_array($call)) { $call=htmlspecialchars($call); }
print_r($call);
if ( is_array($call)) { reset($call); }
echo "</pre><hr>";
} // end function dp() ======================
example:
$debug=true;
dp($some_array_or_object,"Label for object");