getBacktrace()
| From: | Eric Stewart | Date: | Mon, 06 Oct 2003 20:57:36 +0000 |
| Subject: | getBacktrace() | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8310@lists.php.net to get a copy of this message | ||
I'm writing a class that logs errors to a file and writes an appropriate message to the screen.
I'm currently causing an intentional error in the DB class which throws a DB_Error. I check for the error and if it exists I write the errors. I'm trying to use getBacktrace() which is clearly defined in the PEAR_Error class. I'm using PHP 4.3.0 which is the requirement for this function to work, but I keep getting an error saying that getbacktrace() is undefined.
Here is the code:
$user ='foo' ;
$pass ='bar' ;
$host ='localhost' ;
$db_name ='clients_db' ;
// Data Source Name: This is the universal connection string
$dsn ="mysql://$user:$pass@$host/$db_name" ;
// DB::connect will return a PEAR DB object on success
// or an PEAR DB Error object on error
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$db =DB :: connect ($dsn );
if(DB::isError($db)) {
print $db->getMode().'<br>';
print $db->getCallback().'<br>';
print $db->getMessage().'<br>';
print $db->getCode().'<br>';
print $db->getType().'<br>';
print $db->getUserInfo().'<br>';
print $db->getDebugInfo().'<br>';
print $db->getBacktrace('function').'<br>';
}
Here is the error
Fatal error: Call to undefined function: getbacktrace() in /Library/WebServer/Documents/PearInstalled/PEAR/MYExamples/Errors/db_error.php on line 36
What do you think?