Php: Get rid of E_DEPRECATED error messages

18.10.2013 Web

I've got E_DEPRECATED error messages even though error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT is set in php.ini.

The problem

E_ALL includes all errors and warnings, as supported, except of level E_STRICT prior to PHP 5.4.0. A comment in php.ini claims that E_ALL & ~E_NOTICE & ~E_STRICT will show all errors, except for notices and coding standards warnings. Furthermore it recommends to use E_ALL & ~E_DEPRECATED & ~E_STRICT in production environments. But it didn't work for me: E_DEPRECATED error messages still showed up.

Solution

On the page PHP Manual: Predefined Constants you can find all available error constants. If you compose the value for error_reporting by using all single constants, you're able to leave any unwanted constant out:

php.ini
            
error_reporting = E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_USER_DEPRECATED | E_STRICT
            
        

In the line above the constant E_DEPRECATED is missing. This does the trick for me. Dont' forget to restart Apache after changing php.ini.

Did you like the content? If you want to do something good for me, you can pour a little coffee into my empty pot.
Just click the PayPal.Me-Button* below. Thank you very much!

*For more information on our PayPal.Me link, see Impressum & Datenschutz