0

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?

1
  • How did you found that it doesn't work? Btw, what if file is not found in the handler's include? Commented May 17, 2011 at 0:21

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.