Categories
Archives
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- March 2009
- February 2009
- January 2009
- August 2008
- July 2008
- June 2008
- November 2007
- October 2007
- July 2007
- June 2007
- April 2007
- January 2007
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
Tools




Wise Advice from a Signature
I was searching for a quick and easy way of renaming an array key without altering the order of the array elements, when I stumbled upon this thread. While it didn’t help me accomplish my goal, I did enjoy Mark Baker’s signature:
I’d say his estimate is low, and that it is more like 95% of PHP problems can be resolved by turning on error reporting.
I think part of the issue is that everyone recommends “for security” to turn off error reporting on production websites. That’s fine I suppose, but only if your site has some way of telling you it is broken (e.g., an emailer that sends you error logs, an error message on the screen that you can see or someone will email to you, etc..). Just having a log isn’t enough. It is unreasonable to expect someone to waste time looking at an error log that should be empty. Spend 5 minutes and write yourself a little script to email the error log to you (or search Google and find one that is already pre-built), set up a cron, and then fix your bugs when they come rolling in.
I think what drives me even crazier is when people turn error reporting off to hide “safe” errors/warnings (i.e., non-fatal), like undefined index, undefined variable, or deprecated errors. The company I work for recently hired a contractor to help get us up to speed on an open source application. We turned on error reporting, and suddenly the app was spewing warnings left and right. Our contractor’s advice? Turn off error reporting.
But the error messages are there for a reason. If PHP is telling you that you are trying to use a variable or index that isn’t there, then it doesn’t matter if it isn’t a fatal error: your code is broken. It is trying to do something that doesn’t make any sense, and the code needs fixed. 99% of the time this is as easy as setting defaults on your variables or adding a few isset()‘s into your code.
So please, for the sake of the children, turn on error reporting.
Related Posts: