Page 1 of 1

get_error_handler_name() ?

Posted: Mon May 11, 2009 11:44 am
by kaisellgren
Hi,

Is there a way to get the current error handler name? I'm writing a library so I have to fetch this dynamically or I would need to take an additional parameter, which I want to avoid...

Re: get_error_handler_name() ?

Posted: Mon May 11, 2009 11:56 am
by Mark Baker
kaisellgren wrote:Is there a way to get the current error handler name? I'm writing a library so I have to fetch this dynamically or I would need to take an additional parameter, which I want to avoid...

Code: Select all

 
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
   return false;
}
 
$old_error_handler = set_error_handler("userErrorHandler");
set_error_handler($old_error_handler);
echo $old_error_handler;
 
Note that if the default error handler is being used, set_error_handler() will return NULL, so you'd need to trap for this

Re: get_error_handler_name() ?

Posted: Mon May 11, 2009 12:21 pm
by kaisellgren
Oh I didn't notice set_error_handler() returns it ;). Thanks.