How do i hide deprecated errors in php?

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.

How do i hide deprecated errors in php?

asked May 10, 2010 at 15:12

How do i hide deprecated errors in php?

2

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);

Toby Allen

10.8k11 gold badges73 silver badges124 bronze badges

answered May 10, 2010 at 15:14

RobusRobus

7,7875 gold badges45 silver badges65 bronze badges

8

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.

How do i hide deprecated errors in php?

answered Feb 24, 2012 at 7:38

How do i hide deprecated errors in php?

codefreakcodefreak

6,7213 gold badges41 silver badges50 bronze badges

I needed to adapt this to

error_reporting = E_ALL & ~E_DEPRECATED

answered Aug 21, 2010 at 9:22

How do i hide deprecated errors in php?

Simon HSimon H

19.5k13 gold badges66 silver badges118 bronze badges

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.

answered Mar 28, 2014 at 18:11

CamaleoCamaleo

1,08013 silver badges14 bronze badges

0

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);

How do i hide deprecated errors in php?

answered May 10, 2010 at 15:15

KrekerKreker

2,3803 gold badges21 silver badges27 bronze badges

1

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...

How do i hide deprecated errors in php?

answered Oct 9, 2011 at 2:44

How do i hide deprecated errors in php?

sudipsudip

2,6591 gold badge29 silver badges40 bronze badges

0

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.

How do i hide deprecated errors in php?

answered Jan 24, 2013 at 13:18

AudriusAudrius

1171 silver badge2 bronze badges

0

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

answered Feb 10, 2017 at 11:04

realteborealtebo

22k34 gold badges104 silver badges174 bronze badges

3

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);

answered Dec 16, 2017 at 10:00

How do i hide deprecated errors in php?

1

How do I turn off display errors in PHP?

Use a text editor to modify the .htaccess file as follows:.
To prevent PHP from displaying error messages, add the following line: php_flag display_errors Off..
To allow PHP to display error messages, add the following line: php_flag display_errors On..

How do I turn off deprecated warnings in WordPress?

As an interim solution, it is simple to suppress PHP deprecation warnings by disabling WP_DEBUG mode, or (more advanced) by removing E_DEPRECATED from your error_reporting setting.

What is deprecated error in PHP?

These changes can result in warnings and error messages when you update your version of PHP and run existing code. Using these deprecated functions will result in the creation of warnings or errors, which can be problematic, or at least annoying. The code may still run, but it might result in unusual behaviors.

How do I turn off PHP notices?

The simplest and most convenient way to turn off notices is through the php. ini file settings. All you need to do is searching for the line of code error_reporting . Here, you will see a line of Default Value: E_ALL.