問題描述

我的服務器正在運行 php 5.3,我的 wordpress 安裝正在將這些錯誤發送給我,導致 my 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 。

最佳解決方案

您可以通過調用以下函數在代碼中執行此操作。

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

要麼

error_reporting(E_ALL ^ E_DEPRECATED);

次佳解決方案

我需要適應這個

error_reporting = E_ALL & ~E_DEPRECATED

第三種解決方案

只能得到錯誤,導致應用程序停止工作使用:

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

這將停止顯示通知,警告和棄用錯誤。

第四種方案

以上所有答案都是正確的。由於沒有人暗示如何關閉 php 中的所有錯誤,我想在這裏提及:

error_reporting(0); // Turn off warning, deprecated,
                    // notice everything except error

有人可能會覺得有用……

第五種方案

我只是遇到一個類似的問題,一個 SEO 插件發出大量的警告,使我的博客磁盤使用超出計劃限制。

我發現在 wp-config.php 文件中需要 wp-settings.php 之後,必須包含 error_reporting 命令:

   require_once( ABSPATH .'wp-settings.php' );
   error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );

通過這樣做,不再有警告,通知和廢棄的行都附加到您的錯誤日誌文件中!

在 WordPress 3.8 測試,但我猜這是適用於每個安裝。

第六種方案

您必須編輯 php 配置文件。結束了

error_reporting = E_ALL

並替換為 error_reporting = E_ALL ^ E_DEPRECATED

如果您無法訪問配置文件,您可以將此行添加到 php wordpress 文件 (也可以是 headers.php)

error_reporting(E_ALL ^ E_DEPRECATED);

第七種方案

在文件 wp-config.php 中,您可以找到常量 WP_DEBUG,確保它設置為 false 。

define('WP_DEBUG', false);

這是針對 wordpress 3.x

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。