2 simple debugging tips for WordPress developers

preview_player
Показать описание
If you are anything like me you often find yourself having to dump PHP variables to the page in order to see what they contain.

Also, if you are like me you look at these and think they are terribly formatted and hard to read.

In this short video I share 2 simply tips to make debugging easier to read and understand which I am sure will save you time.

----------
Follow us here:

Рекомендации по теме
Комментарии
Автор

On my website, which has been translated into five languages ​​with Polylang, all pages except Dutch suddenly show a 404 error message. I tried to solve this with a 301 but it doesn't help. I read that debugging would help but I have no knowledge of how to do that. Greetings from Eddy

Traveltoppereu
Автор

I have a snippet I wrote for my editor similar to your wp_var_dump for all projects use. Had never considered coloring it. Yours looks more appealing.

TechiePress
Автор

I either use xDebug - that way it's easy to see the call stack as well as all variables and structures, and inline outputting.
When I have to I will insert inline debug information - the trick is to make sure all instances are removed BEFORE uploading to the live server. Easy for automated deployments, but another step when manually FTP'ing.
For inline outputting I prefer using a code snippet in VS Code. That way it will work for any PHP project.
Here's a view of my php.json file.

"Pre": {
"prefix": "pre",
"body": [
"echo '<pre>' . print_r($foo, true) . '</pre>';",
],
"description": "Echo Var Dump"
}





In the use case for debugging on a live server (sometimes required) then the output debug file is my preferred route - avoids screen dumps which visitors will see.

TonyGirling