PHP Warnings on or off?

I managed to break a website yesterday without realising it. This sounds really bad, but in this case breaking things is the first step on the road to fixing things. Let me explain.

What was unusual about this particular incident was that I didn't actually break the site - I just turned on the PHP warnings that said the site was broken.

All of a sudden, the site owner was getting emails from visitors saying his site was broken.

However, the site had been broken all along. The errors were still happening, and whatever data was being saved may have all kinds of errors in it.

PHP error messages

With PHP, you can choose what sort of errors you want displayed on the screen. All, errors, warnings, notices, or none.

If you choose none, then your clients don't get to see any ugly PHP errors on your site.

If you show all errors, then your clients do see all these ugly messages. Changes are you or them will see the error, and then do something about it (fix it).

I consider it much better to have the error visible than to have the site failing silently and alerting nobody that there is a problem.

A better way again is to log the errors to a file, and have the log emailed to your developer every so often. This way, your clients don't get to see the nasty looking messages, but the developer does.

Errors happen all the time, so it's worthwhile to take the time to understand how the error reporting system works, and to ensure that errors don't happen quietly and unnoticed.
Back to Main listing | Back to Homepage

Comments

sourabh - Aug 20, 2007

do u have any working code that logs the error in a text file and mail it to developer on regular basis. actually i can write it myself but as u know its sunday eve and im feeling a bit lazy... :)

post a comment

Post Comment

*
*


Visual CAPTCHA

*
Code is not case-sensitive
*

We welcome comments on this article, provided they have something to contribute. Please note that all links will be created using the nofollow attribute. This is a spam free zone. HTML is stripped from comments, but BBCode is allowed.