Created
September 18, 2009 15:12
-
-
Save samsouder/189099 to your computer and use it in GitHub Desktop.
A little PHP function to get a succinct string of function backtraces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A little PHP function to get a succinct string of function backtraces. | |
function debug_backtrace_format() | |
{ | |
$bt = array_slice(debug_backtrace(), 1); // shift off the call to debug_backtrace_format() | |
return join(', ', array_map(create_function('$a', 'return $a["function"] ."() (". $a["file"] .":". $a["line"] .")";'), $bt)); | |
} | |
function test() | |
{ | |
test2(); | |
} | |
function test2() | |
{ | |
echo debug_backtrace_format(); | |
} | |
test(); | |
// OUTPUTS: | |
// test2() (/Users/ssouder/Desktop/Stubs/stub.php:11), test() (/Users/ssouder/Desktop/Stubs/stub.php:19) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment