跳至內容
工具

WP_DEBUG Configurator

Turn on the debug log without breaking your live site

在你的瀏覽器裡執行。什麼都不會被上傳。

Where is this site?

This changes the recommendation, not just the wording. The safe configuration on a live site is genuinely different from the useful one on your laptop.

Verdict

Options
wp-config.php

Paste these ABOVE the line that says /* That's all, stop editing! */ — anything below it is ignored, which is why so many people report that WP_DEBUG 'does nothing'.

關於WP_DEBUG Configurator

Generate the WP_DEBUG constants that write errors to a log file instead of printing them to your visitors. The default WP_DEBUG snippet most sites copy will display PHP errors publicly — this one will not.

FAQ

常見問題

在運作中的網站上啟用 WP_DEBUG 安全嗎?

只有在 WP_DEBUG_DISPLAY 設為 false 的情況下才安全。單獨開啟時,WP_DEBUG 會把 PHP 通知和警告——包含你伺服器的絕對檔案路徑——直接印在你訪客載入的頁面上。幾乎每篇教學都只丟給你那一行就結束了。把它和 WP_DEBUG_LOG 搭配,並將 WP_DEBUG_DISPLAY 設為 false,這樣就安全了。

WordPress 的除錯紀錄會存到哪裡?

預設是 wp-content/debug.log。值得知道的是:在許多主機上那個檔案是公開可抓取的——任何人都可以在瀏覽器裡請求它。你可以改為傳一個路徑給 WP_DEBUG_LOG,把紀錄寫在網頁根目錄之上,這個工具會幫你產生。

我把 WP_DEBUG 設成 true,卻什麼都沒發生。為什麼?

幾乎一定是因為這個常數被加在 wp-config.php 裡「That's all, stop editing!」那一行「下面」。那一行之後的所有東西都會被忽略。把它移到上面。