Last active
November 7, 2018 17:19
-
-
Save marcelovani/4677f72f3762be783c7abdc13027ce8b to your computer and use it in GitHub Desktop.
Shorter version of debug_backtrace
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
function short_backtrace($limit = 0) { | |
$r = []; | |
$t = debug_backtrace(); | |
$t = array_slice($t, 1, $limit); | |
for ($i = 0; $i <= $limit; $i++) { | |
if (isset($t[$i]['file'])) { | |
$f = ''; | |
if (isset($t[$i]['function'])) { | |
$f = ' called ' . $t[$i]['function'] . '()'; | |
} | |
$r[] = [ | |
'Line' => $t[$i]['file'] . ':' . $t[$i]['line'] . $f, | |
'With args' => $t[$i]['args'], | |
]; | |
} | |
} | |
return $r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment