Yogesh Chauhan's Blog

Debugging in WordPress Part 1: WP_DEBUG

in WordPress on January 24, 2021

This article was published on WordPress.org

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.


// This enables debugging.
define( 'WP_DEBUG', true );


// This disables debugging.
define( 'WP_DEBUG', false );

Note: The true and false values in the example are not surrounded by apostrophes (‘) because they are boolean (true/false) values. If you set constants to ‘false’, they will be interpreted as true because the quotes make it a string rather than a boolean.

It is not recommended to use WP_DEBUG or the other debug tools on live sites; they are meant for local testing and staging installs.

PHP Errors, Warnings, and Notices

Enabling WP_DEBUG will cause all PHP errors, notices and warnings to be displayed.

This is likely to modify the default behavior of PHP which only displays fatal errors and/or shows a white screen of death when errors are reached.

Showing all PHP notices and warnings often results in error messages for things that don’t seem broken, but do not follow proper data validation conventions inside PHP.

These warnings are easy to fix once the relevant code has been identified, and the resulting code is almost always more bug-resistant and easier to maintain.

Deprecated Functions and Arguments

Enabling WP_DEBUG will also cause notices about deprecated functions and arguments within WordPress that are being used on your site.

These are functions or function arguments that have not been removed from the core code yet but are slated for deletion in the near future.

Deprecation notices often indicate the new function that should be used instead.


amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS? #Aug 1 What is Zdog? #Aug 1 How to add before after image effect using pure CSS? #Jul 31 Add animation to your skills bar using CSS #Jul 31 Use SwiperJS to create mobile touch sliders fast
You might also like these
CSS backface-visibility PropertyCSSfor @each loop in SCSSSCSSHigher Order Functions in JavaScript with ExamplesJavaScriptSteps to Secure a VPNMiscellaneousHow to read Standard Input in Swift?SwiftLEFT JOIN in PostgresPostgres