Created
April 8, 2015 12:51
-
-
Save onigoetz/9255492ce9cc8ba51fc9 to your computer and use it in GitHub Desktop.
Debug code quickly
This file contains hidden or 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 | |
function quick_backtrace() { | |
$trace = debug_backtrace(); | |
echo '<pre>'; | |
foreach ($trace as $entry) { | |
if (__FUNCTION__ == $entry['function']) continue; | |
if (array_key_exists('file', $entry)) { | |
$file = (strlen($entry['file']) >= 30)? '…'.substr($entry['file'], -29) : $entry['file']; | |
echo "$file:$entry[line] "; | |
} | |
echo array_key_exists('type', $entry)? "$entry[class]$entry[type]$entry[function]" : $entry['function']; | |
echo "()\n"; | |
} | |
echo '</pre>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment