Jump to content

Recommended Posts

How can I completely kill the - oh, so helpful! - PHP error messages from being sent back to the browser?  I have played around with set_error_handler and followed the guidelines in the docs but to no avail.  Maybe I am doing something wrong. Perhaps there is a clear tutorial on how to deal with this somewhere out there?

Link to comment
https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/
Share on other sites

Thank you for the replies guys - including the smartarse ones.  I guess it is just so much easier making mean comments rather than actually trying to read, understand and reply.

 

The answer is this - ini_set, set_error_handler etc can only trap error reporting if the script gets loaded and interpreted.  If for any reason whatsoever this does not happen then evidently default PHP error reporting will kick in.  The right way to stop this is by setting display_errors = Off in php.ini.

The problem with switching errors off completely is that if your app does produce an error then it may take you a long time to realize it is occuring. If you are experienced enough then the best method (one that can be implemented into all your projects) is to write an error handler (if using PHP5 you could extend the Exception class for example). Obvoiusly this cannot catch syntax errors but you should have tested the app before going live anyway. An error handler could log the errors in a database or email them to you. From the users point of view the app may display a page that states, "the application has performed an error, sorry, blah, blah, etc" and then cleanly redirect them to another part of the app.

including the smartarse ones.  I guess it is just so much easier making mean comments rather than actually trying to read, understand and reply.

 

That's hardly necessary - especially when they have a point. You should try fixing the errors, instead of just masking them.

 

----------------

Now playing: Red Hot Chili Peppers - Emit Remmus

via FoxyTunes

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.