note 102499 modified in debugger by danbrown

From: Date: Thu, 17 Feb 2011 20:44:49 +0000
Subject: note 102499 modified in debugger by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177090@lists.php.net to get a copy of this message
In my debug function I added some functionallity to print out from where the function was called: <?php function debug($value=''){ $btr=debug_backtrace(); $line=$btr[0]['line']; $file=basename($btr[0]['file']); print"<pre>$file:$line</pre>\n"; if(is_array($value)){ print"<pre>"; print_r($value); print"</pre>\n"; }elseif(is_object($value)){ $value.dump(); }else{ print("<p>&gt;${value}&lt;</p>"); } } ?> Thereby it is easy to keep the overview if you debug more variables simultaneously or, if the program crashes somewhere, just throw in a few debug() and you'll easily see how far the program comes --was-- In my debug function I added some functionallity to print out from where the function was called: function debug($value=''){ $btr=debug_backtrace(); $line=$btr[0]['line']; $file=basename($btr[0]['file']); print"<pre>$file:$line</pre>\n"; if(is_array($value)){ print"<pre>"; print_r($value); print"</pre>\n"; }elseif(is_object($value)){ $value.dump(); }else{ print("<p>&gt;${value}&lt;</p>"); } } Thereby it is easy to keep the overview if you debug more variables simultaneously or, if the program crashes somewhere, just throw in a few debug() and you'll easily see how far the program comes http://php.net/manual/en/debugger.php

« previous php.notes (#177090) next »