note 21691 added to function.set-error-handler
| From: | bsAThncDOTcc@php.net | Date: | Thu, 23 May 2002 13:57:58 +0000 |
| Subject: | note 21691 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30939@lists.php.net to get a copy of this message | ||
my solution to use a method as errorhandler, someone's might interested in it:
(sorry for the missing indention, but some lines are too long)
<?php
error_reporting( E_ALL );
ini_alter( 'register_globals', 0 );
function my_set_error_handler($callback_func)
{
if (!is_array($callback_func))
return set_error_handler($callback_func);
if (!is_object($callback_func[0]) ||
!method_exists($callback_func[0], $callback_func[1]))
return false;
$GLOBALS['_ERROR_HANDLER_OBJECT'] = &$callback_func[0];
$GLOBALS['_ERROR_HANDLER_METHOD'] = $callback_func[1];
function error_handler_passthru($errno, $errstr, $errfile, $errline, $errcontext)
{
$GLOBALS['_ERROR_HANDLER_OBJECT']->
$GLOBALS['_ERROR_HANDLER_METHOD']($errno, $errstr, $errfile, $errline, $errcontext);
}
return set_error_handler('error_handler_passthru');
}
class error_handler
{
function error ($errno, $errstr, $errfile, $errline, $errcontext)
{
echo "<pre>errno: $errno
errstr: $errstr
errfile: $errfile
nerrline: $errline
errcontext:\n";
print_r($errcontext);
}
}
$eh = new error_handler();
$oldhandler = my_set_error_handler(array( &$eh, 'error' ));
// let's see if error handler works
$i++;
?>
--
http://www.php.net/manual/en/function.set-error-handler.php
http://master.php.net/manage/user-notes.php?action=edit+21691
http://master.php.net/manage/user-notes.php?action=delete+21691
http://master.php.net/manage/user-notes.php?action=reject+21691