note 13860 added to function.print-r.php

From: Date: Fri, 06 Jul 2001 20:24:58 +0000
Subject: note 13860 added to function.print-r.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15046@lists.php.net to get a copy of this message
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"); http://www.php.net/manual/en/function.print-r.php

« previous php.notes (#15046) next »