How to remove deprecated errors while running new php versions

x theme
(Last Updated On: July 10, 2014)

If you’re running PHP code on the server having latest version of PHP, and you’re using deprecated code of PHP. Then, you might get the error something like below:

Deprecated: Assigning the return value of new by reference is deprecated

Note: Errors code be different, but for deprecated error, the error will have Deprecated written.

So, for removing the deprecated errors while running new php versions, you can use following code on the top of the PHP file.

Method 1

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

Method 2

error_reporting(E_ALL ^ E_DEPRECATED);

Method 3


Method 4

This method is for WordPress. Use the code inside wp-config.php. Remeber to look at the file code first, because the code is already there, so don’t paste the code. Just add “true” or “false” for enabling/disabling the errors.

define('WP_DEBUG', false);

About the author


Leave a Reply

Your email address will not be published. Required fields are marked *