screenshot of better print_r function in VIM

Quick PHP Object Output

I stumbled upon this simple debug function the other day after searching for a better way of searching through a bunch of WordPress objects.

I have always used the native PHP print_r() function for this in the past, but when it comes to large objects, it just becomes rather unreadable to get the whole object displayed on one line.

Although, I’ve been looking in to using the WordPress plugin debug bar for achieving the same thing. If you know that you’ll be doing a lot of debugging on one single website, it might be better to set up this plugin instead.

However, if you just need something quick to just throw in there whenever you need to output some objects, this will work just fine.

For WordPress, just put it in your functions.php, and your good to go.

Reference
Nicer looking print_r / var_dump