Prettify print_r output
If you deal with objects or arrays in PHP you probably have heard of print_r, in a nutshell it prints all of an object or array. Trouble is, by default it can look very ugly and isn't super helpful for debugging because html doesn't respect the whitespace. This is exactly what the <pre> tag was meant for and by wrapping it around print_r you get much more readable output. Here's a 3 line function that makes it so.
function pretty_print($arg) {
echo '<pre>';
print_r($arg);
echo '</pre>';
}Written by Montana Flynn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Did you know?
PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#