WordPress Debug Mode for Fun and Profit

Sometimes when you’re puttering around in your WordPress PHP code you might do something you didn’t mean to do and end up with something like this.

Not very helpful. It’s particularly problematic if it occurs when you update the MySQL database from Production or pull down the latest source from your GitHub Repository. Enter WordPress Debug mode. Debug mode is enabled in wp-config.php shown here.

WP_DEBUG is set to “false” by default. We’ll set it to “true” and load the site again.

Parse error: Unexpected what…?  That’s okay, we’ve got the php filename and line number displayed for us.  Let’s take a look.

Geez. Some weirdness of two ” characters tripping up the PHP Interpreter.

After removing the weirdness we are back in action!

WordPress Debug mode is great for general development as well, like if you’re writing a Plugin. I use JetBrains’ IntelliJ IDEA for PHP development and it has excellent debugging capabilities. However, enabling Debug mode is in many cases more efficient than using the IDE. I’ve not been doing WordPress development for very long, so I don’t know if keeping development WordPress sites in Debug mode is the convention or not. Regardless, I think I’ll keep it on for a while and see how I like it.