FredAt Posted July 24, 2008 Share Posted July 24, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/ Share on other sites More sharing options...
MFHJoe Posted July 24, 2008 Share Posted July 24, 2008 ini_set('display_errors', 'Off'); At the top of your PHP file may do the trick, providing your webhost allows you to use that command (some don't). Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-598852 Share on other sites More sharing options...
revraz Posted July 24, 2008 Share Posted July 24, 2008 I can see your next post "Why doesn't my code work? It shows no errors and it's blank!" Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-598886 Share on other sites More sharing options...
Jabop Posted July 24, 2008 Share Posted July 24, 2008 Or my code doesn't do what I want and I don't know why Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-598890 Share on other sites More sharing options...
Third_Degree Posted July 24, 2008 Share Posted July 24, 2008 error_reporting( 0 ); Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-598942 Share on other sites More sharing options...
FredAt Posted July 25, 2008 Author Share Posted July 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-599277 Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 This is only advised when the site is running live, not in development. Also your mysql_query's may cause errors if u have set them to die on error. Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-599399 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-599410 Share on other sites More sharing options...
LemonInflux Posted July 25, 2008 Share Posted July 25, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/116456-killing-php-error-messages/#findComment-599412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.