Php – Hide STRICT errors on PHP 5.4

PHPphp.iniphp5

I've upgraded from PHP 5.3 to PHP 5.4 today. Now my script is displaying a lot of error messages. How to hide them without using error_reporting(0); inside php file ?

I use this:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

Best Answer

In PHP 5.4 E_STRICT became part of E_ALL - (documentation). My recommendation would be to turn the directive to display errors to off, and to log errors instead, this would be done by setting the following in your php.ini:

display_errors = off
log_errors = on
error_log = /path/to/logs/php_error.log

If you do not want to go down this route and still wish to display errors and simply emulate the PHP <5.4 functionality you would be best off doing something like this:

error_reporting = E_ERROR | E_WARNING | E_PARSE

It should also be mentioned that various people have reported the inability to exclude E_STRICT from E_ALL in such a way as you have tried as a bug, so this might change in a later release to allow for the functionality you are used to.