#11: Suppressing All Error Messages

Sometimes you may have a script that works fine, but PHP still insists on kicking up a fuss. In other instances, if something should go wrong, you don't want your users to see an ugly error message (which reveals the sort of information hackers just love to see).

Fortunately, you can suppress all error messages through a setting in your php.ini file:

display_errors = Off

You should use this setting in your production environment so that you don't have to worry about the Internet at large seeing your PHP diagnostic messages. If you need to see these diagnostic messages to root out problems, use the following configuration setting to send the messages to the Apache log:

log_errors = On

If you like, you can even send ...

Get Wicked Cool PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.