note 106638 added to function.debug-backtrace
| From: | b dot thax dot dcg at gmail dot com | Date: | Wed, 23 Nov 2011 20:04:32 +0000 |
| Subject: | note 106638 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184643@lists.php.net to get a copy of this message | ||
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> <font
color=\"red\">{$a[\'line\']}</font> <font
color=\"green\">{$a[\'function\']} ()</font> -- ".
dirname( $a[\'file\'] ). "/<br />";' ) );
}
----
Server IP: 69.147.83.197
Probable Submitter: 62.43.99.56
----
Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php
Edit -- https://master.php.net/note/edit/106638
Del: integrated -- https://master.php.net/note/delete/106638/integrated
Del: useless -- https://master.php.net/note/delete/106638/useless
Del: bad code -- https://master.php.net/note/delete/106638/bad+code
Del: spam -- https://master.php.net/note/delete/106638/spam
Del: non-english -- https://master.php.net/note/delete/106638/non-english
Del: in docs -- https://master.php.net/note/delete/106638/in+docs
Del: other reasons-- https://master.php.net/note/delete/106638
Reject -- https://master.php.net/note/reject/106638
Search -- https://master.php.net/manage/user-notes.php