Introduction
When we update our PHP version to the most recent version, we occasionally may receive a “Deprecation Notice” notice warning. This is due to the possibility that some functions may be depreciated but remain useful.
Since the code still functions even though it has been depreciated by the most recent PHP version, we often do not need to worry too much about this kind of warnings.

Deprecation Notice
By editing the settings in your php.ini file, we can disable this type of warning and hide it. Search for “error reporting” in any code editor. Then,
set “error reporting = E ALL & E DEPRECATED” as the value.
Below are the other common values for “error_reporting”.
- E_ALL (Show all errors, warnings and notices including coding standards.)
- E_ALL & ~E_NOTICE (Show all errors, except for notices)
- E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
- E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
Typically, we would simply conceal deprecated warnings since our code continues to function even though some PHP functions have been retired. Additionally, it is best to display any additional failures so we can confirm that our code functions as intended.
Even while you won’t want to start getting E DEPRECATED signals in a live environment, you could want to show them when developing to make it simple to find and fix code that uses out-of-date functions.
Making it safe for earlier versions of PHP
The only catch with the above error_reporting examples is that if you’re running the same code on e.g. PHP 5.2 as well as PHP 5.3 then you’ll get a notice in PHP 5.2 (and earlier) like “Notice: Use of undefined constant E_DEPRECATED”.
To avoid triggering this notice check if E_DEPRECATED is defined:
if(defined('E_DEPRECATED')) { error_reporting(E_ALL &~ E_DEPRECATED); } if(defined('E_DEPRECATED')) { error_reporting(error_reporting() & ~E_DEPRECATED); }
It would be best to use new functions provided by the latest version of PHP and try not to use deprecated functions. This is to prevent any errors or more warnings in the future. Furthermore, the new functions might be even more stable and perform faster.