As a developer, I work with E_NOTICE turned on. Recently though, I was asked why E_NOTICE errors should be fixed. The only reason that I could come up with was that it is best practice to correct those problems.
Does anyone else have any reasons to justify the extra time/cost spent to correct these problems?
More specifically, why should a manager spend the money to have these fixed if the code already works?
SUMMARY
The PHP Runtime Configuration Docs give you some idea why:
Here’s a more detailed explanation of each…
1. TO DETECT TYPOS
The main cause of
E_NOTICEerrors is typos.Example – notice.php
Output without E_NOTICE
Wrong! You didn’t mean that!
Output with E_NOTICE
In PHP, a variable that doesn’t exist will return null rather than causing an error, and that could cause code to behave differently than expected, so it’s best to heed
E_NOTICEwarnings.2. TO DETECT AMBIGUOUS ARRAY INDEXES
It also warns you about array indexes that might change on you, e.g.
Example – code looks like this today
Output without E_NOTICE
Example – tomorrow you include a library
and the library does something like this:
New output
Empty, because now it expands to:
and there is no key
Maryin$arr.Output with E_NOTICE
If only the programmer had
E_NOTICEon, PHP would have printed an error message:3. THE BEST REASON
If you don’t fix all the
E_NOTICEerrors that you think aren’t errors, you will probably grow complacent, and start ignoring the messages, and then one day when a real error happens, you won’t notice it.