shustry icon

Nice backtrace as string

shustry | PRO | 03/01/19 11:45:19 AM UTC | 0 ⭐ | 239 👁️ | Never ⏰ | []
PHP |

370 B

|

None

|

0 👍

/

0 👎

function getTrace()
{
    $v = function ($a, $k) { return array_key_exists($k, $a) ? $a[$k] : ''; };
    $s = [];
    $tr = debug_backtrace();
    array_shift($tr);
    foreach ($tr as $h => $e) {
        $s [] = vsprintf('#%d %s:%s %s%s%s()', [ ++$h, $e['file'], $e['line'], $v($e, 'class'), $v($e, 'type'), $e['function'] ]);
    }
    return implode(PHP_EOL, $s);
}

Comments