Handle PHP Fatal errors and Parse Errors

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
balaji4php
Forum Newbie
Posts: 2
Joined: Sun Dec 07, 2008 2:22 am

Handle PHP Fatal errors and Parse Errors

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Handle PHP Fatal errors and Parse Errors

Post 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?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Handle PHP Fatal errors and Parse Errors

Post 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.
balaji4php
Forum Newbie
Posts: 2
Joined: Sun Dec 07, 2008 2:22 am

Re: Handle PHP Fatal errors and Parse Errors

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Handle PHP Fatal errors and Parse Errors

Post 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).
Post Reply