Turn off deprecated errors php 5.3

2019-01-13 07:07发布

My server is running php 5.3 and My wordpress install is spitting these errors out on me causing the 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.

10条回答
姐就是有狂的资本
2楼-- · 2019-01-13 07:11

I needed to adapt this to

error_reporting = E_ALL & ~E_DEPRECATED
查看更多
虎瘦雄心在
3楼-- · 2019-01-13 07:13

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

查看更多
▲ chillily
4楼-- · 2019-01-13 07:17

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

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

This will stop showing notice, warning and deprecated errors.

查看更多
在下西门庆
5楼-- · 2019-01-13 07:18

All the answers above 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......

查看更多
老娘就宠你
6楼-- · 2019-01-13 07:18

Just replace below code in wp-config.php file

define( 'WP_DEBUG', true ); to define( 'WP_DEBUG', true );

查看更多
趁早两清
7楼-- · 2019-01-13 07:24

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.

查看更多
登录 后发表回答