Skip to content

Instantly share code, notes, and snippets.

@pjt33
Last active December 19, 2015 04:39
Show Gist options
  • Save pjt33/5898943 to your computer and use it in GitHub Desktop.
Save pjt33/5898943 to your computer and use it in GitHub Desktop.
PHP stacktrace in a loggable/echoable form.
$st = debug_backtrace();
$lineNo = '';
$stackTrace = '';
foreach ($st as $line)
{
if (isset($line['class'])) $stackTrace .= $line['class'].$line['type'].$line['function'].' at line '.$lineNo . "\n";
else $stackTrace .= $line['function'].' in '.$line['file'].' line '.$lineNo . "\n";
$lineNo = $line['line'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment