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

SeanDowney picture SeanDowney · Sep 16, 2008 · Viewed 20.3k times · Source

Typically I use E_ALL to see anything that PHP might say about my code to try and improve it.

I just noticed a error constant E_STRICT, but have never used or heard about it, is this a good setting to use for development? The manual says:

Run-time notices. Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.

So I'm wondering if I'm using the best error_reporting level with E_ALL or would that along with E_STRICT be the best? Or is there any other combination I've yet to learn?

Answer

Jim picture Jim · Sep 16, 2008

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);