note 101498 modified in function.debug-backtrace by danbrown
| From: | danbrown@php.net | Date: | Tue, 21 Dec 2010 15:48:22 +0000 |
| Subject: | note 101498 modified in function.debug-backtrace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175100@lists.php.net to get a copy of this message | ||
Here's my little updated contribution - it prints colorful output in the way I prefer. Define
a helper function isRootIp() that contains an array including your IP; then calls to bt() simply
return, so you can sprinkle backtraces in live sites w/o anyone knowing.
<?php
function bt()
{
if( ! isRootIp() )
{
return false;
}
array_walk( debug_backtrace(), create_function( '$a,$b', 'print "<br
/><b>". basename( $a[\'file\'] ). "</b> <font
color=\"red\">{$a[\'line\']}</font> <font
color=\"green\">{$a[\'function\']} ()</font> -- ".
dirname( $a[\'file\'] ). "/";' ) );
}
?>
--was--
Here's my little updated contribution - it prints colorful output in the way I prefer. Define
a helper function isRootIp() that contains an array including your IP; then calls to bt() simply
return, so you can sprinkle backtraces in live sites w/o anyone knowing.
function bt()
{
if( ! isRootIp() )
{
return false;
}
array_walk( debug_backtrace(), create_function( '$a,$b', 'print "<br
/><b>". basename( $a[\'file\'] ). "</b> <font
color=\"red\">{$a[\'line\']}</font> <font
color=\"green\">{$a[\'function\']} ()</font> -- ".
dirname( $a[\'file\'] ). "/";' ) );
}
http://php.net/manual/en/function.debug-backtrace.php