WP DEBUG

来自WordPress中文文档
Zhuozuran讨论 | 贡献2016年5月6日 (五) 06:13的版本 (1个版本)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

wordpress.org.cn

WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the "debug" mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress.

For information on other debugging tools built into WordPress see Debugging in WordPress

Usage

Enable debugging.

define( 'WP_DEBUG', true );

Disable debugging

define( 'WP_DEBUG', false );

includeonlydiv style=clear:both; background-color:#ffffff; border:1px solid #c6d9e9; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;NOTE: The true and false values in the example are not set in apostrophes (') because they are boolean values. If you set WP_DEBUG to 'false' that will be interpreted as true because it is a string rather than a boolean./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude

WP_DEBUG_LOG and WP_DEBUG_DISPLAY

WP_DEBUG_LOG and WP_DEBUG_DISPLAY are additional PHP constants that extend WP_DEBUG, and may also be used to debug WordPress.

WP_DEBUG_LOG

WP_DEBUG_LOG is a companion to WP_DEBUG that causes all errors to also be saved to a debug.log log file inside the /wp-content/ directory. This is useful if you want to review all notices later or need to view notices generated off-screen (e.g. during an AJAX request or wp-cron run).

define( 'WP_DEBUG_LOG', true );

WP_DEBUG_DISPLAY

WP_DEBUG_DISPLAY is another companion to WP_DEBUG that controls whether debug messages are shown inside the HTML of pages or not. The default is 'true' which shows errors and warnings as they are generated. Setting this to false will hide all errors. This should be used in conjunction with WP_DEBUG_LOG so that errors can be reviewed later.

define( 'WP_DEBUG_DISPLAY', false );

History

The WP_DEBUG option was added in WordPress Version 2.3.1.

Starting with WordPress version 2.3.2, database errors are printed only if WP_DEBUG is set to true. In earlier versions, database errors were always printed. (Database errors are handled by the wpdb class and are not affected by PHP's error settings.)

Starting with WordPress version 2.5, setting WP_DEBUG to true also raises the error reporting level to E_ALL and activates warnings when deprecated functions or files are used; otherwise, WordPress sets the error reporting level to E_ALL ^ E_NOTICE ^ E_USER_NOTICE.