I have a legacy app that requires register_globals
and magic_quotes_gpc
to be enabled. I have my error_reporting
set to E_ALL & ~E_DEPRECATED
because I still want to see any warnings.
When I run the PHP CLI I get the following
$ php -d "error_reporting=E_ALL & ~E_DEPRECATED" -v
PHP Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP 5.3.3 (cli) (built: Mar 30 2011 13:51:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
Why is it showing the deprecation messages as warnings? Shouldn't they be in the E_DEPRECATED
level?
It seems I have to not show warnings to get them to go away
$ php -d "error_reporting=E_ALL & ~E_WARNING" -v
PHP 5.3.3 (cli) (built: Mar 30 2011 13:51:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
I could change my error_reporting
to E_ALL & ~E_DEPRECATED & ~E_WARNING
but then it wouldn't show warnings for my webapp. Any suggestions? Do I have to use a separate php.ini
for the CLI?
This post shows how to suppress E_DEPRECATED error messages. To show all errors other than E_DEPRECATED in the php.ini file, adjust the error_reporting setting as shown below. Note this should only be done for installs of PHP 5.3+. To suppress notices as well: You can either straight out set the error reporting level like so:
There are PHP notices and deprecated messages filling up the /var/log/httpd/ssl_error_log file. This problem can be eliminated by updating the php .ini file. The advisory messages do not indicate a fatal error. To determine the location of your php .ini file, execute the following command:
If you receive errors regarding function deprecation, the following two methods can tell PHP to simply stop mentioning deprecated functions or coding: You can add the following line to your php5.ini file: error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE Or you may add the following line to a PHP file itself, inside existing or new <?php ?> tags:
To show all errors other than E_DEPRECATED in the php.ini file, adjust the error_reporting setting as shown below. Note this should only be done for installs of PHP 5.3+. To suppress notices as well:
Change error_reporting
to E_ALL & ~E_DEPRECATED & ~E_WARNING
.
Then, at the beginning of your code set:
error_reporting(E_ALL | E_STRICT);
Initial PHP checks have passed and now you have your complete error-reported environment. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With