public static function fatalError($msg)
{
echo '<h1>Fatal Error</h1>';
echo '<p>' . $msg . '</p>';
if (!function_exists('debug_backtrace')) {
return;
}
echo '<h2>Debug Backtrace</h2>';
echo '<pre>';
$index = -1;
foreach (debug_backtrace() as $t) {
$index++;
if ($index == 0) {
// hide the backtrace of this function
continue;
}
echo '#' . $index . ' ';
if (isset($t['file'])) {
echo basename($t['file']) . ':' . $t['line'];
} else {
echo '<PHP inner-code>';
}
echo ' -- ';
if (isset($t['class'])) {
echo $t['class'] . $t['type'];
}
echo $t['function'] . '(';
if (isset($t['args']) && sizeof($t['args']) > 0) {
$count = 0;
foreach ($t['args'] as $item) {
if (is_string($item)) {
$str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
if (strlen($item) > 70) {
echo "'" . substr($str, 0, 70) . "...'";
} else {
echo "'" . $str . "'";
}
} else {
if (is_int($item) || is_float($item)) {
echo $item;
} else {
if (is_object($item)) {
echo get_class($item);
} else {
if (is_array($item)) {
echo 'array(' . count($item) . ')';
} else {
if (is_bool($item)) {
echo $item ? 'true' : 'false';
} else {
if ($item === null) {
echo 'NULL';
} else {
if (is_resource($item)) {
echo get_resource_type($item);
}
}
}
}
}
}
}
$count++;
if (count($t['args']) > $count) {
echo ', ';
}
}
}
echo ")\n";
}
echo '</pre>';
exit(1);
}