get_error_handler_name() ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

get_error_handler_name() ?

Post 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...
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: get_error_handler_name() ?

Post 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
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: get_error_handler_name() ?

Post by kaisellgren »

Oh I didn't notice set_error_handler() returns it ;). Thanks.
Post Reply