关闭 PHP 5.3 中已弃用的错误

2022-08-30 06:48:26

我的服务器正在运行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

这很烦人,但我不想关闭屏幕错误报告。如何禁用这些麻烦的已弃用警告?

我正在运行WordPress 2.9.2。


答案 1

可以通过调用以下函数在代码中执行此操作。

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

error_reporting(E_ALL ^ E_DEPRECATED);

答案 2

若要仅获取导致应用程序停止工作的错误,请使用:

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

这将停止显示通知、警告和已弃用的错误。


推荐