error_handler problem

From: Date: Fri, 19 Apr 2002 13:08:22 +0000
Subject: error_handler problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1215@lists.php.net to get a copy of this message
Hi folk, I want to use my own error handler function including pear_error_handler. It works great with one problem, I can't output the right error line. If I use 4th parameter of the error handler function I always get the line of the trigger function and not the line of the actual error. My code fragment: ______________________________________________________________________ function php_error_handler($errno, $errstr, $errfile, $errline) {
    $errfile2 = $_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'];
    $errline2 = __LINE__; // also wrong, of cource
    if (($errno == E_ERROR) || ($errno == E_USER_ERROR))
    {
print "<br /><b>Fatal error [$errno]</b>: $errstr in <b>$errfile2</b> on line <b>".$errline."</b>\n<br />\n"; exit($errno);
    }
    else if (($errno == E_WARNING) || ($errno == E_USER_WARNING))
    {
print <br /><b>Error [$errno]</b>: $errstr in <b>$errfile</b> on line <b>$errline</b>\n<br />\n"; exit($errno);
    }
    else if ($errno == E_USER_NOTICE)
    {
echo "<b>Warning [$errno]</b>: $errstr "; echo "in <b>$errfile</b> on line <b>$errline</b>\n<br />\n";
    }
} set_error_handler('php_error_handler'); function pear_error_handler($err_obj) { $error_string = $err_obj->getMessage() . '<br /><br />' . $err_obj->getDebugInfo(). '<br /><br />'; trigger_error($error_string, E_USER_ERROR); } require_once("DB.php"); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_error_handler'); _____________________________________________________________________________ Can someone give me a solution for this problem? I use PHP 4.2.0RC4 with register_global=Off Ciao Alex... -- ** PGP public key available ** No hardware designer should be allowed to produce any piece of hardware until three software guys have signed off for it. -- Andy Tanenbaum

« previous php.pear.general (#1215) next »