Turn off deprecated errors php 5.3

会有一股神秘感。 提交于 2019-11-27 11:30:50
Robus

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

I needed to adapt this to

error_reporting = E_ALL & ~E_DEPRECATED

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.

sudip

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

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.

Audrius

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

You have to edit the php configuration file. Fin the line

error_reporting = E_ALL

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!