Description
print a backtrace to help find out where something is called from and how to debug itThe output from debug_backtrace() is an array – from 0 to n of the calls
- [file] is the file name
- [line] is the line number
- [function] is the method used to get the file: include, require_once
- [args] are parameters
- [class]
- [object]
- [type] -> = method call, :: = static method call, nothing for function call
C:\apache\htdocs\wordpress\wp-content\themes\hsoh0922bp\functions.php(12:0) 2011-09-27T16:22:49+00:00 backtrace Array ( [0] => Array ( [file] => C:\apache\htdocs\wordpress\wp-settings.php [line] => 280 [function] => include ) [1] => Array ( [file] => C:\apache\htdocs\wordpress\wp-config.php [line] => 130 [args] => Array ( [0] => C:\apache\htdocs\wordpress\wp-settings.php ) [function] => require_once ) [2] => Array ( [file] => C:\apache\htdocs\wordpress\wp-load.php [line] => 29 [args] => Array ( [0] => C:\apache\htdocs\wordpress\wp-config.php ) [function] => require_once ) [3] => Array ( [file] => C:\apache\htdocs\wordpress\wp-blog-header.php [line] => 12 [args] => Array ( [0] => C:\apache\htdocs\wordpress\wp-load.php ) [function] => require_once ) [4] => Array ( [file] => C:\apache\htdocs\wordpress\index.php [line] => 17 [args] => Array ( [0] => C:\apache\htdocs\wordpress\wp-blog-header.php ) [function] => require ) )
Usage
bw_lazy_backtrace();Parameters
Returns
voidSource
File name: oik-bwtrace/includes/bwtrace.phpLines:
1 to 57 of 57
function bw_lazy_backtrace() { global $bw_trace_on; if ($bw_trace_on) { $backtrace = debug_backtrace(); //bw_trace( $backtrace, __FUNCTION__, __LINE__, __FILE__, "backtrace" ); $file = ""; foreach ( $backtrace as $i => $call ) { $function = $call['function']; $file = bw_array_get( $call, 'file', $file ) ; $file = bw_trace_file_part( $file ); $line = bw_array_get( $call, 'line', 0 ); $args = bw_array_get( $call, 'args', array() ); $cargs = count( $args ); switch ( $cargs ) { case 0: $targs = NULL; break; //case 1: //$targs = $args[0]; //if ( strpos( " require require_once include include_once ", $function ) ) { $function .= "(".$targs.")"; //} //break; default: $targs = $args; $sep = '('; foreach ( $targs as $targ ) { if ( is_object( $targ ) ) { $function .= $sep."object"; } elseif ( is_array( $targ ) ) { $function .= $sep."array"; } elseif ( is_scalar( $targ ) ) { $function.=$sep . $targ; } elseif ( is_null( $targ) ) { $function.=$sep.'null'; } else { $function .= $sep."unsupported" ; } $sep = ','; } $function .= ')'; } // This produces far too much //bw_trace( $targs, $function, $line, $file, $i ); // this is not much better //bw_trace( $i, $function, $line, $file, "backtrace" ); /* 0.0018 467368 1. {main}() C:\apache\htdocs\wordpress\wp-admin\options-general.php:0 0.0033 561816 2. require_once('C:\apache\htdocs\wordpress\wp-admin\admin.php') C:\apache\htdocs\wordpress\wp-admin\options-general.php:10 0.0040 578248 3. require_once('C:\apache\htdocs\wordpress\wp-load.php') C:\apache\htdocs\wordpress\wp-admin\admin.php:30 */ $line = "$i. $function $file:$line $cargs\n"; bw_trace_log( $line ); } } }View on GitHub View on Trac
Called by
1 to 2 of 2
Invoked by
Calls
1 to 3 of 3
