What is the recommended error_reporting() setting for development? What about E_STRICT? What is the recommended error_reporting() setting for development? What about E_STRICT? php php

What is the recommended error_reporting() setting for development? What about E_STRICT?


In PHP 5, the things covered by E_STRICT are not covered by E_ALL, so to get the most information, you need to combine them:

 error_reporting(E_ALL | E_STRICT);

In PHP 5.4, E_STRICT will be included in E_ALL, so you can use just E_ALL.

You can also use

error_reporting(-1);

which will always enable all errors. Which is more semantically correct as:

error_reporting(~0);


Use the following in php.ini:

error_reporting = E_ALL | E_STRICT

Also you should install Xdebug, it can highlight your errors in blinding bright colors and print useful detailed information.

Never let any error or notice in your code, even if it's harmless.


In my opinion, the higher you set the error reporting level in development phase, the better.

In a live environment, you want a slightly (but only slightly) reduced set, but you want them logged somewhere that they can't be seen by the user (I prefer syslog).

http://php.net/error_reporting

E_ALL | E_STRICT for development with PHP before 5.2.0.

5.2 introduces E_RECOVERABLE_ERROR and 5.3 introduces E_DEPRECATED and E_USER_DEPRECATED. You'll probably want to turn those on if you're running one of those versions.

If you wanted to use magic numbers you could just set the error_reporting value to some fairly high value of 2^n-1 - say, 16777215, and that would really just turn on all the bits between 1..n. But I don't think using magic numbers is a good idea...

In my opinion, PHP has dropped the ball a bit by having E_ALL not really be all. But apparently it's going to be fixed in PHP 6...