note 102499 modified in debugger by danbrown
[email protected] Thu, 17 Feb 2011 12:44:49 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
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>>${value}<</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>>${value}<</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