note 101498 modified in function.debug-backtrace by danbrown

From: 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> &nbsp; <font color=\"red\">{$a[\'line\']}</font> &nbsp; <font color=\"green\">{$a[\'function\']} ()</font> &nbsp; -- ". 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> &nbsp; <font color=\"red\">{$a[\'line\']}</font> &nbsp; <font color=\"green\">{$a[\'function\']} ()</font> &nbsp; -- ". dirname( $a[\'file\'] ). "/";' ) ); } http://php.net/manual/en/function.debug-backtrace.php

« previous php.notes (#175100) next »