note 80711 added to function.debug-backtrace
| From: | aryel at iku dot com dot br | Date: | Tue, 29 Jan 2008 22:40:01 +0000 |
| Subject: | note 80711 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135566@lists.php.net to get a copy of this message | ||
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
----
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/80711
Del: integrated -- https://master.php.net/note/delete/80711/integrated
Del: useless -- https://master.php.net/note/delete/80711/useless
Del: bad code -- https://master.php.net/note/delete/80711/bad+code
Del: spam -- https://master.php.net/note/delete/80711/spam
Del: non-english -- https://master.php.net/note/delete/80711/non-english
Del: in docs -- https://master.php.net/note/delete/80711/in+docs
Del: other reasons-- https://master.php.net/note/delete/80711
Reject -- https://master.php.net/note/reject/80711
Search -- https://master.php.net/manage/user-notes.php