note 106638 deleted from function.debug-backtrace by danbrown

From: Date: Tue, 29 Nov 2011 15:51:08 +0000
Subject: note 106638 deleted from function.debug-backtrace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184794@lists.php.net to get a copy of this message
Note Submitter: b dot thax dot dcg at gmail dot com ---- This is a simple method I'm using to print the current stack trace but with a given to start printing it. It's handy when you want do not want the actual print function in the trace or any other. The output has been based on 'Bill Getas' comment. // Globals that control the depth $print_trace_depth_count; $print_trace_depth_depth; /** * Print stack trace. * * $depth: Depth to start printing */ function print_trace($depth=1) { global $print_trace_depth_count, $print_trace_depth_depth; $print_trace_depth_count = 0; $print_trace_depth_depth = $depth; array_walk( debug_backtrace(), create_function( '$a,$b', 'global $print_trace_depth_count, $print_trace_depth_depth; $print_trace_depth_count++; if ($print_trace_depth_count<=$print_trace_depth_depth) return; print "<b>". basename( $a[\'file\'] ). "</b> &nbsp; <font color=\"red\">{$a[\'line\']}</font> &nbsp; <font color=\"green\">{$a[\'function\']} ()</font> &nbsp; -- ". dirname( $a[\'file\'] ). "/<br />";' ) ); }

« previous php.notes (#184794) next »