Reputation: 1
I'm trying to setup a custom landing error page in the event there is php errros, I'm using:
function xhandler($number,$string,$file,$line,$context){
include('/path/to/error_text_page.tpl');
exit;
}
error_reporting(E_ALL ^ E_NOTICE);
set_error_handler('xhandler',E_ALL ^ E_NOTICE);
This isn't working though, anyone know what I'm doing wrong?
Upvotes: 0
Views: 538
Reputation: 523
According to php.net and to continue with Dr. Molle's reply:
The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.
That might explain your problem.
Upvotes: 1
Reputation: 117354
You need to know that not every error-type can be handled by set_error_handler, e.g. parse/fatal errors.
Try
trigger_error("Testing xhandler", E_USER_ERROR);
for testing.
Upvotes: 0