views:

58

answers:

2

2 days ago we switched in our office from PHP 5.2.x to 5.3.x and it caused some problems at first, but we managed to fix 'em pretty fast.

Since lots of bugfixes were done by looking at error logs, something popped up in my mind.

Well, there are all these PHP Notices about undefined variables and other, as I consider, not urgent, messages. I did reconfigure one of my recent projects, to stop showing these notices, but then there is a question... Is it considered good practice, to not log notices and only look for real errors? And why?

I'm kind of confused at the moment, because we have more than enough running sites at the moment, and I have no idea — should I leave those sites alone, or should I reconfigure them to log only really bad stuff.

+8  A: 

It's good practice to not generate notices in the first place, since they're a code smell.

Ignacio Vazquez-Abrams
code smell :P nice term
Harsha M V
Code smell is a good one, yeah! ^^, And yes, with logging I meant generating 'em. Basicly, "notices" is one of those things which should be disabled by default on production site?
Tom
Logging and generating are two different things. It is possible to generate a notice even if it is not logged.
Ignacio Vazquez-Abrams
@Tom, there are two schools of thought about that. Notices should certainly be enabled in Development, but the biggest reason they should be disabled in Production is because too many developers have them turned off... :-/
staticsan
Notices are debug messages. And it's not a good idea to suppress them with huge piles of isset decorations. Applied inconsiderate it might hide actual pitfalls.
mario
Thanks for information guys, much appreciated!
Tom
+1  A: 

We have notices running on our pre-production environments so we can detect any potential errors or bad practices before we release to production. On production, we only log the bad stuff.

abrereton
And you're considering 'undefined variables' as a bad practice? Should I avoid those (start defining them)? I'm working on a new website system at the moment, therefore interested in any information.
Tom
Yes! You should not use any undefined variables. PHP has a reliable check to see if a variable is undefined or not.
staticsan
Seriously, Tom, are there people consciously writing code with undefined variables? ick
Andrew Heath