Forum Moderators: coopster
I assume I can ignore E_WARNING since the only errors I've seen of that level are undefined variables.
What about E_STRICT? My understanding is that PHP is suggesting code changes that would make my code more future proof, but aren't causing problems right now. The only one I've come across is that var is deprecated, although I still need the code to work with PHP4 so I need to use var.
All the others, including the E_USER set because some of my classes throw user errors, seem to need to stop execution. I would rather have a non-fatal error display a clean page with an error message than have the non-fatal message sporadic through the page.
You don't need to check for STRICT errors in PHP4 code versions, but if you are developing in PHP5 you should watch for them. Many classes, as you have noted, will generate STRICT errors if they are written to work in PHP4 installations. Those specific to PHP5 should check for STRICT errors and be cleaned up too.
I assume I can ignore E_WARNING since the only errors I've seen of that level are undefined variables.
Maybe you're confusing notices with warnings. An undefined variable will throw a notice (
$var .= 'bla', without first defining $var). A warning usually means something is not working. For example, on my Windows box
mail()always leads to a warning, as there is no mailing software available to PHP.
include(non-existing file)will also cause a warning. The script will carry on after a warning, but the result might not be what you'd expect...
I don't ignore any errors, not even NOTICE or WARNING errors. Every error should be noted and fixed or at least handled in some way.
And I agree that every error should be handled, but isn't looking at the error and deciding that the user doesn't need to see that I didn't declare $x before using it and that the code can just go on without displaying an error handling the error?
I guess the real question is... are there E_NOTICE or E_STRICT warnings that will cause problems in a production site other than just not being technically correct? Yes, I know that if ($_GET['something']=='123') can cause a notice but the code still functions. Same thing with using var $x in a class on a PHP5 server. An E_STRICT warning comes up but ignoring it doesn't seem to cause a problem.
Or is there a list of all, or a pretty good chunk of, the various errors messages broken down by type?
I've never had any big problems with notices, except in situations where they are output to html and may break header().
But here's a problem scenario: a lazy coder who always writes
$array[foo]in stead of
$array['foo']. "Hey, it works, and I read on WebmasterWorld that I can safely ignore those pesky notices." But one day he or a co-worker introduces a new constant somewhere else in the application:
define('foo', 'bar'). Suddenly problems galore.