Page 1 of 1

Handle PHP Fatal errors and Parse Errors

Posted: Sun Dec 07, 2008 2:33 am
by balaji4php
Hi,
Is there a way to handle PHP Fatal errors and Parse Errors??? As if there is a syntax error, i want to catch the error and display the user defined message instead of php error but i could not caught that error. Please hep me in how to handle those.Error handler works fine with warnings and notice but not the Fatal errors and Parse Errors. Please hep me out of this

Re: Handle PHP Fatal errors and Parse Errors

Posted: Sun Dec 07, 2008 6:03 am
by Chris Corbyn
You can't do this really. Especially for parse errors. Parse errors occur at a very low level, before your PHP code has actually been interpreted. There's also little reason I could see for needing this.

Are you able to elaborate on why you need this?

Re: Handle PHP Fatal errors and Parse Errors

Posted: Sun Dec 07, 2008 8:08 am
by Eran
There are some 'hacks' to get what you want, read the comments on the custom error_handler - http://www.php.net/manual/en/function.s ... .php#68470.

Re: Handle PHP Fatal errors and Parse Errors

Posted: Sun Dec 07, 2008 10:54 am
by balaji4php
I need to handle all type of errors. If its a parse or fatal error, I need to handle those errors and display a customized message to the users. I appreciate your help.
Chris Corbyn wrote:You can't do this really. Especially for parse errors. Parse errors occur at a very low level, before your PHP code has actually been interpreted. There's also little reason I could see for needing this.

Are you able to elaborate on why you need this?

Re: Handle PHP Fatal errors and Parse Errors

Posted: Mon Dec 22, 2008 11:49 pm
by Weirdan
Chris Corbyn wrote:You can't do this really.
Well, you could, but on the other level of the stack (meaning not in php). You may handle those errors on webserver level (by using ErrorDocument in apache config, or by parsing output for some specific strings).