Skip to content

Instantly share code, notes, and snippets.

@onigoetz
Created April 8, 2015 12:51
Show Gist options
  • Save onigoetz/9255492ce9cc8ba51fc9 to your computer and use it in GitHub Desktop.
Save onigoetz/9255492ce9cc8ba51fc9 to your computer and use it in GitHub Desktop.
Debug code quickly
<?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