Voting

: min(five, seven)?
(Example: nine)

The Note You're Voting On

Gemorroj
12 years ago
Another variation formatting backtrace.
Parameter $ignore to ignore the extra calls.
<?php
/**
* Getting backtrace
*
* @param int $ignore ignore calls
*
* @return string
*/
protected function getBacktrace($ignore = 2)
{
$trace = '';
foreach (
debug_backtrace() as $k => $v) {
if (
$k < $ignore) {
continue;
}

array_walk($v['args'], function (&$item, $key) {
$item = var_export($item, true);
});

$trace .= '#' . ($k - $ignore) . ' ' . $v['file'] . '(' . $v['line'] . '): ' . (isset($v['class']) ? $v['class'] . '->' : '') . $v['function'] . '(' . implode(', ', $v['args']) . ')' . "\n";
}

return
$trace;
}
?>

<< Back to user notes page

To Top