note 80712 added to function.debug-backtrace

From: Date: Tue, 29 Jan 2008 22:40:51 +0000
Subject: note 80712 added to function.debug-backtrace
Groups: php.notes 
Request: Send a blank email to php-notes+get-135567@lists.php.net to get a copy of this message
An easy function to pull all details of the debug backtrace: <?php function getDebugBacktrace($NL = "<BR>") { $dbgTrace = debug_backtrace(); $dbgMsg .= $NL."Debug backtrace begin:$NL"; foreach($dbgTrace as $dbgIndex => $dbgInfo) { $dbgMsg .= "\t at $dbgIndex ".$dbgInfo['file']." (line {$dbgInfo['line']}) -> {$dbgInfo['function']}(".join(",",$dbgInfo['args'])")$NL"; } $dbgMsg .= "Debug backtrace end".$NL; return $dbgMsg; } ?> Then you can call it anywhere you want to get a string with the debug backtrace in readable format (i.e. your error handling function) <?php $backtrace = getDebugBacktrace(); echo "Fatal error! Cannot connect to database!"; echo $backtrace; ?> If you're running on command line, you might want to replace the line split. You can do that thru the function argument: <?php $backtrace = getDebugBacktrace("\n"); echo "Error! Server is running out of foos! Dumping error backtrace"; echo $backtrace; ?> Hope that helps, Aryel ---- Server IP: 69.147.83.197 Probable Submitter: 201.6.85.217 ---- Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php Edit -- https://master.php.net/note/edit/80712 Del: integrated -- https://master.php.net/note/delete/80712/integrated Del: useless -- https://master.php.net/note/delete/80712/useless Del: bad code -- https://master.php.net/note/delete/80712/bad+code Del: spam -- https://master.php.net/note/delete/80712/spam Del: non-english -- https://master.php.net/note/delete/80712/non-english Del: in docs -- https://master.php.net/note/delete/80712/in+docs Del: other reasons-- https://master.php.net/note/delete/80712 Reject -- https://master.php.net/note/reject/80712 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135567) next »