atw*_*pub 121 php wordpress deprecation-warning
我的服务器正在运行php 5.3和我的wordpress安装将这些错误吐出来,导致我的session_start()中断.
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
Run Code Online (Sandbox Code Playgroud)
这很烦人,但我不想关闭屏幕错误报告.如何禁用这些令人讨厌的弃用警告?
我正在运行Wordpress 2.9.2.
Rob*_*bus 196
您可以通过调用以下函数在代码中执行此操作.
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
Run Code Online (Sandbox Code Playgroud)
要么
error_reporting(E_ALL ^ E_DEPRECATED);
Run Code Online (Sandbox Code Playgroud)
Sim*_*n H 22
我需要适应这个
error_reporting = E_ALL & ~E_DEPRECATED
Run Code Online (Sandbox Code Playgroud)
cod*_*eak 19
要仅获取错误导致应用程序停止工作使用:
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
Run Code Online (Sandbox Code Playgroud)
这将停止显示通知,警告和弃用的错误.
sud*_*dip 13
以上所有答案都是正确的.由于没有人暗示如何关闭php中的所有错误,我想在此提及:
error_reporting(0); // Turn off warning, deprecated,
// notice everything except error
Run Code Online (Sandbox Code Playgroud)
有人可能觉得它很有用......
Cam*_*leo 11
我刚遇到类似的问题,其中一个SEO插件发出大量警告,使我的博客磁盘使用超出了计划限制.
我发现你必须在wp-config.php文件中的wp-settings.php require 之后包含error_reporting命令:
require_once( ABSPATH .'wp-settings.php' );
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
Run Code Online (Sandbox Code Playgroud)
通过执行此操作,不会再将警告,通知或弃用行附加到错误日志文件中!
在WordPress 3.8上测试,但我想它适用于每个安装.
小智 8
在文件wp-config.php中,您可以找到常量WP_DEBUG,确保将其设置为false.
define('WP_DEBUG', false);
Run Code Online (Sandbox Code Playgroud)
这适用于wordpress 3.x.
你必须编辑php配置文件.完成线
error_reporting = E_ALL
Run Code Online (Sandbox Code Playgroud)
并替换为
error_reporting = E_ALL ^ E_DEPRECATED
如果您无权访问配置文件,可以将此行添加到php wordpress文件(可能是headers.php)
error_reporting(E_ALL ^ E_DEPRECATED);
Run Code Online (Sandbox Code Playgroud)
我倾向于使用这种方法
$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);
Run Code Online (Sandbox Code Playgroud)
这样我就不会意外关闭我需要的东西