Turn off deprecated errors in PHP 5.3

前端 未结 9 1452
天涯浪人
天涯浪人 2020-12-02 11:32

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 re         


        
相关标签:
9条回答
  • 2020-12-02 12:11

    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);
    
    0 讨论(0)
  • 2020-12-02 12:11

    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);
    
    0 讨论(0)
  • 2020-12-02 12:13

    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.

    0 讨论(0)
  • 2020-12-02 12:16

    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.

    0 讨论(0)
  • 2020-12-02 12:16

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

    0 讨论(0)
  • 2020-12-02 12:25

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

    0 讨论(0)
提交回复
热议问题