Forum Moderators: coopster
During an error I display $error_backtrace
$error_backtrace = back_trace();
Use the below routine...
function back_trace() {
$output = ''; //"Trace @ ".sql_datetime()."<br>\n";
$backtrace = debug_backtrace();
$indent = 0;
foreach ($backtrace as $bt) {
$args = '';
if (is_array($bt['args'])) {
foreach ($bt['args'] as $a) {
if (!empty($args)) {
$args .= ', ';
}
switch (gettype($a)) {
case 'integer':
case 'double':
$args .= $a;
break;
case 'string':
$a = htmlspecialchars(substr($a, 0, 64)).((strlen($a) > 64)? '...' : '');
$args .= "\"$a\"";
break;
case 'array':
$args .= 'Array('.count($a).')';
break;
case 'object':
$args .= 'Object('.get_class($a).')';
break;
case 'resource':
$args .= 'Resource('.strstr($a, '#').')';
break;
case 'boolean':
$args .= $a? 'True' : 'False';
break;
case 'NULL':
$args .= 'Null';
break;
default:
$args .= 'Unknown';
}
}
}
if ((basename($bt['file'])!= 'inc_error_handler.php')) { // only trace this error handler if the error originated in here
$output .= str_repeat(">",$indent);
$indent++;
$output .= basename($bt['file'])." @ {$bt['line']}\t{$bt['class']}\t{$bt['type']}\t{$bt['function']}\t($args)\t\n";
}
}
return $output;
}
-----
The test for "inc_error_handler.php" stop me tracing all the way into my error handler.