Turn off deprecated errors in PHP 5.3

PhpWordpressDeprecation Warning

Php Problem Overview


My server is running PHP 5.3 and my WordPress install is spitting these errors out on me, causing my session_start() to break.

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 647

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 662

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 669

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 676

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 712

This is annoying, but I do not want to turn off on screen error reporting. How do I disable these bothersome deprecated warnings?

I am running WordPress 2.9.2.

Php Solutions


Solution 1 - Php

You can do it in code by calling the following functions.

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

or

error_reporting(E_ALL ^ E_DEPRECATED);

Solution 2 - Php

To only get those errors that cause the application to stop working, use:

error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));

This will stop showing notices, warnings, and deprecated errors.

Solution 3 - Php

I needed to adapt this to

error_reporting = E_ALL & ~E_DEPRECATED

Solution 4 - Php

I just faced a similar problem where a SEO plugin issued a big number of warnings making my blog disk use exceed the plan limit.

I found out that you must include the error_reporting command after the wp-settings.php require in the wp-config.php file:

   require_once( ABSPATH .'wp-settings.php' );
   error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );

by doing this no more warnings, notices nor deprecated lines are appended to your error log file!

Tested on WordPress 3.8 but I guess it works for every installation.

Solution 5 - Php

You have to edit the PHP configuration file. Find the line

error_reporting = E_ALL

and replace it with:

error_reporting = E_ALL ^ E_DEPRECATED

If you don't have access to the configuration file you can add this line to the PHP WordPress file (maybe headers.php):

error_reporting(E_ALL ^ E_DEPRECATED);

Solution 6 - Php

All the previous answers are correct. Since no one have hinted out how to turn off all errors in PHP, I would like to mention it here:

error_reporting(0); // Turn off warning, deprecated,
                    // notice everything except error

Somebody might find it useful...

Solution 7 - Php

In file wp-config.php you can find constant WP_DEBUG. Make sure it is set to false.

define('WP_DEBUG', false);

This is for WordPress 3.x.

Solution 8 - Php

I tend to use this method

$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);

In this way I do not turn off accidentally something I need

Solution 9 - Php

this error occur when you change your php version: it's very simple to suppress this error message

To suppress the DEPRECATED Error message, just add below code into your index.php file:

init_set('display_errors',False);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionatwellpubView Question on Stackoverflow
Solution 1 - PhpRobusView Answer on Stackoverflow
Solution 2 - PhpcodefreakView Answer on Stackoverflow
Solution 3 - PhpSimon HView Answer on Stackoverflow
Solution 4 - PhpCamaleoView Answer on Stackoverflow
Solution 5 - PhpKrekerView Answer on Stackoverflow
Solution 6 - PhpsudipView Answer on Stackoverflow
Solution 7 - PhpAudriusView Answer on Stackoverflow
Solution 8 - PhprealteboView Answer on Stackoverflow
Solution 9 - PhpdheerendraView Answer on Stackoverflow