note 50635 deleted from function.debug-print-backtrace by aidan

From: Date: Tue, 15 Mar 2005 09:36:34 +0000
Subject: note 50635 deleted from function.debug-print-backtrace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86453@lists.php.net to get a copy of this message
Note Submitter: pear at laurent-laville dot org ---- 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 !

« previous php.notes (#86453) next »