Debugging is an essential skill for any developer. This tutorial will show you 11 powerful ways to debug WordPress and PHP errors. The first item in the list is the famous WP_Debug, then we’ll jump into some more advanced methods.
First, let’s list the types of common PHP errors:
A – Notice: This is the least important error message you will see with PHP. It does not necessarily mean something is wrong, but there is possible improvement suggested.
Example: null element passed to a function that expect a string.
B – Warning: It’s a more severe error, but does not cause script termination.
Example: giving include() a file that does not exist.
C – Fatal error: This is a dangerous indicator of something going really wrong, and the script terminated.
Example: calling a non-existing function.
1 – WP_DEBUG
WordPress has a global constant to specify the needed level of debugging: WP_DEBUG. Along with this constant, comes two another important ones: WP_DEUBG_DISPLAY, and WP_DEBUG_LOG.
WP_DEBUG is used to set the debugging mode on or off. WP_DEUBG_DISPLAY shows errors or hides them. Finally, WP_DEBUG_LOG saves your error messages in wp-content/debug.log.
Source: https://managewp.org/articles/13660/debugging-wordpress-11-powerful-tips-and-techniques
source https://williechiu40.wordpress.com/2016/10/19/debugging-wordpress-11-powerful-tips-and-techniques/
No comments:
Post a Comment