getTraceAsString()); /* print to screen in simple format */ print mydebug_bt(); trigger_error("user triggered error", E_USER_ERROR); } error_log('calling a()', 0, './php_errors.log'); a('alpha'); /* simplify and beatify the output of a dump of debug_backtrace() */ function mydebug_bt() { $stack = ''; $i = 1; $trace = debug_backtrace(); unset($trace[0]); // remove call to this function from stack trace foreach($trace as $node) { $stack .= "#$i ".$node['file'] ."(" .$node['line']."): "; if(isset($node['class'])) { $stack .= $node['class'] . "->"; } $stack .= $node['function'] . "()" . PHP_EOL; $i++; } return $stack; }