* @license BSD */ namespace Domframework; /** Display the backtrace in HTML with clicks to display the content */ class Backtrace { /** Display the backtrace in the browser * use: \backtrace::show (debug_backtrace ()); * @param array $backtrace The backtrace to display */ public static function show($backtrace) { if (! is_array($backtrace)) { throw new \Exception("Backtrace invalid: not an array", 500); } echo "
Debug BackTrace:\n";
foreach ($backtrace as $key => $back) {
echo "";
echo "$key => ";
if (array_key_exists("file", $back)) {
echo $back["file"] . "[" . $back["line"] . "] : ";
}
if (array_key_exists("class", $back)) {
echo $back["class"];
}
echo "::" . $back["function"] . "(";
if (array_key_exists("args", $back)) {
foreach ($back["args"] as $k => $arg) {
if ($k > 0) {
echo ", ";
}
if (is_array($arg)) {
echo "ARRAY";
} elseif (is_object($arg)) {
echo "OBJECT " . get_class($arg);
} elseif (is_bool($arg)) {
echo ($arg === true) ? "true" : "false";
} elseif (is_string($arg)) {
echo "\"$arg\"";
} elseif (is_int($arg) || is_float($arg)) {
echo $arg;
} else {
var_dump($arg);
}
}
}
echo ")";
echo "";
echo "";
print_r($back);
echo "\n";
}
echo "\n";
}
}