Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created November 20, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobus1998/3c41d82a42fc11c20d151df797379524 to your computer and use it in GitHub Desktop.
Save kobus1998/3c41d82a42fc11c20d151df797379524 to your computer and use it in GitHub Desktop.
simple backtrace formatter
<?php
/**
* clear overview of backtrace
*
* @return string
*/
function backTrace($traces = null)
{
$traces = $traces ?? debug_backtrace();
$result = '';
foreach ($traces as $trace)
{
$result .= sprintf("\n%s:%s %s()", $trace['file'], $trace['line'], "{$trace['class']}{$trace['type']}{$trace['function']}");
}
return trim($result, "\n");
}
/* result
path/to/file.php:69 foo::bar()
path/to/file.php:420 bar->foo()
path/to/file.php:1337 fooBar()
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment