objnoob Posted November 16, 2010 Share Posted November 16, 2010 I'd like to set my own error handler function to clear some session variables, but I do not want to completely replace php's internal error handler message reporting. Is there any way to mimic the internal error message reporting so I can define my own error handler function. function myErrorHandler(){ unset($_SESSION['var']); // HERE EXECUTE Normal PHP error message reporting } Thanks Quote Link to comment Share on other sites More sharing options...
simshaun Posted November 16, 2010 Share Posted November 16, 2010 I don't think you can wrap PHP's default error handler without replicating it in your own code. I think the closest you can come is to use set_error_handler to define your own error handling function. Have your custom error handler unset the session vars, call restore_error_handler(), then call trigger_error() using error_get_last() to generate the error string. Edit: Is there a reason you want to use PHP's default error handler? If its just to save you the hassle of coding, check out the docs on set_error_handler. There are some decent implementations in the user comments. Quote Link to comment Share on other sites More sharing options...
objnoob Posted November 17, 2010 Author Share Posted November 17, 2010 Thanks for the reply. I'll check out those implementations. Quote Link to comment Share on other sites More sharing options...
objnoob Posted November 17, 2010 Author Share Posted November 17, 2010 I read the documentation on set_error_handler function, and php docs state: "It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE." So, I'll just return false in my custom handler function. This is exactly what I was looking for. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.