note 30296 added to function.debug-backtrace

From: Date: Thu, 13 Mar 2003 11:51:25 +0000
Subject: note 30296 added to function.debug-backtrace
Groups: php.notes 
Request: Send a blank email to php-notes+get-45210@lists.php.net to get a copy of this message
Pretty print the backtrace(). Functions are indented based on call value, and file is linked using file:// for convenience. Enjoy, John Lim function adodb_backtrace($print=true) { $s = ''; if (PHPVERSION() >= 4.3) { $MAXSTRLEN = 64; $s = '<pre align=left>'; $traceArr = debug_backtrace(); array_shift($traceArr); $tabs = sizeof($traceArr)-1; foreach ($traceArr as $arr) { for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; '; $tabs -= 1; $s .= '<font face="Courier New,Courier">'; if (isset($arr['class'])) $s .= $arr['class'].'.'; foreach($arr['args'] as $v) { if (is_null($v)) $args[] = 'null'; else if (is_array($v)) $args[] = 'Array['.sizeof($v).']'; else if (is_object($v)) $args[] = 'Object:'.get_class($v); else if (is_bool($v)) $args[] = $v ? 'true' : 'false'; else { $v = (string) @$v; $str = htmlspecialchars(substr($v,0,$MAXSTRLEN)); if (strlen($v) > $MAXSTRLEN) $str .= '...'; $args[] = $str; } } $s .= $arr['function'].'('.implode(', ',$args).')'; $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". " file: <a href=\"file:/%s\">%s</a></font>", $arr['line'],$arr['file'],$arr['file']); $s .= "\n"; } $s .= '</pre>'; if ($print) print $s; } return $s; } -- http://www.php.net/manual/en/function.debug-backtrace.php http://master.php.net/manage/user-notes.php?action=edit+30296 http://master.php.net/manage/user-notes.php?action=delete+30296 http://master.php.net/manage/user-notes.php?action=reject+30296

« previous php.notes (#45210) next »