note 50635 added to function.debug-print-backtrace
| From: | pear at laurent-laville dot org | Date: | Sat, 05 Mar 2005 10:07:17 +0000 |
| Subject: | note 50635 added to function.debug-print-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85965@lists.php.net to get a copy of this message | ||
Previous contribution of arisingh is good except that line
$function = ($v["class"]) ...
raise a notice error if there is no class info in the backtrace.
To have a better render with browser and cli and avoid the notice error, i suggest to use instead
code below :
<?php
if (!function_exists('debug_print_backtrace')) {
function debug_print_backtrace() {
if (isset($_SERVER['REQUEST_URI'])) {
$eol = '<br />' . "\n";
} else {
$eol = "\n";
}
$arr = debug_backtrace();
$dum = array_shift($arr);
$ret = '';
for ($i=0; $i < count($arr); $i++){
$v = $arr[$i];
$fileLoc = $v['file'] . ':' . $v['line'];
$function = (isset($v['class'])) ? $v['class'] . '.' .
$v['function'] : $v['function'];
$params = "";
for ($j=0; $j < count($v['args']); $j++){
$p = $v["args"][$j];
$params .= ($params) ? ",$p" : $p;
}
$ret .= "#$i. $function($params) called at [$fileLoc]$eol";
}
echo $ret;
}
}
?>
In PHP4 as in PHP5, call function in the same way !
----
Manual Page -- http://www.php.net/manual/en/function.debug-print-backtrace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50635
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50635&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50635&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50635&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50635&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50635&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50635&report=yes
Search -- http://master.php.net/manage/user-notes.php