Error_reporting settings

I am currently reading the Zend PHP 5.5 certification study guide.
For a development system it advocated setting

error_reporting = E_ALL

For a production environment is advocates setting

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

I have tried looking at the relevant pages but if somebody could explain why these are the recommended settings that would be really useful!

Well, it would be nice to see any error that your script is having (E_ALL) and it’s nice to know if you are using deprecated code (E_DEPRECATED) for learning code that is or going to be obsolete is a waste of time. As for strict code (E_STRICT) it leads to better programming skills for it gives the correct way of coding, though some people have no problem in taking shortcuts.

Doesn’t error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT means all errors but NOT deprecated and NOT strict ?

Also, for the production version, do you want to have errors turned on?

The answer is very simple.

To understand these settings all you need is change your attitude towards error messages.

Despite what general php audience thinks, error messages are your friends, not foes. Error message is the best help a developer could get while trying to solve a problem. Therefore, he has to be shown as much error messages as possible.

Thus advocates E_ALL setting.

As of the deprecated errors, they are not of the immediate help but just a forecast warnings that will pollute production logs, making it harder to trace the actual errors of importance.

Same goes for the E_STRICT.

I prefer using error_reporting(-1); which generates even more errors than E_ALL and regularly check the log file.

I appreciate the recommendation which would have prevented E_WARNINGS from being displayed when a host provider upgraded PHP. The later version changed a default date setting to produce warnings if not explicitly set. I forget the exact function that was something to do with the country code and it is now difficult to check because tapping on a tablet.

FYI, -1 is equal to E_ALL these days, including E_STRICT by default

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.