note 80711 deleted from function.debug-backtrace by nlopess

From: Date: Tue, 29 Jan 2008 23:01:17 +0000
Subject: note 80711 deleted from function.debug-backtrace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135568@lists.php.net to get a copy of this message
Note Submitter: aryel at iku dot com dot br ---- An easy function to pull all details of the debug backtrace: 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) $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: $backtrace = getDebugBacktrace("\n"); echo "Error! Server is running out of foos! Dumping error backtrace"; echo $backtrace; Hope that helps

« previous php.notes (#135568) next »