Read about ...
  • Apple Mac & OSX
  • Internet & Social Media
  • Reviews
  • Security
  • SEO & Marketing
  • Web Design
  • Web Hosting
  • RSS RSS Feed

    How to Suppress PHP Errors on a Production Web Site

    Having left Last.fm no more than 2 weeks ago now, I am in a world where I look at more than a handful of web sites on a daily basis. This is good for my reading and exposure to new thoughts, ideas, news and more, but in terms of exposure to the poor work of the outside world, it’s not so great.

    For the Nth time I have loaded up a well-known online advertising magazine site and been hit with a publicly visible PHP Fatal error. Now it is good practice to use these in the staging and development environment, but to leave them out in the wild, for all and sundry to see is poor practice. Not only does it look poor, but it also exposes information that is less than desirable in the wrong hands.

    How Much Code Is Required?

    As a production manager or developer, all you need to know is that putting the following global function in the head of your code will suppress any reported errors, be they fatals, warnings or notices:

    error_reporting(0);

    At worst, once in place, visitors to your production site will see a blank or partially loaded page, but if your developer’s reviewing the php error logs, there shouldn’t be any problem in spotting any issues, beyond actually catching them in the QA or live environment.

    Bookmark This Article:
    • Digg
    • del.icio.us
    • Facebook
    • Google
    • Furl
    • LinkedIn
    • Live
    • Ma.gnolia
    • MySpace
    • Pownce
    • Reddit
    • StumbleUpon
    • Technorati
    • E-mail this story to a friend!
    • Print this article!
    • Yahoo! Buzz
    • YahooMyWeb
    • TwitThis

    Why not join the conversation? Leave a reply.