note 21691 deleted from function.set-error-handler by sniper
| From: | sniper@php.net | Date: | Wed, 21 May 2003 03:26:19 +0000 |
| Subject: | note 21691 deleted from function.set-error-handler by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48708@lists.php.net to get a copy of this message | ||
Note Submitter: bsAThncDOTcc
----
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++;
?>