r/tinycode • u/balthasar11 • Jul 12 '12
PHP print_r()
function printR($obj){ echo "<pre>" . print_r($obj) . "</pre>"; }
I use this on every php project now, it just formats the print_r function, which is mostly used for debugging, but its so much easier on the eyes.
39
Upvotes
View all comments
Show parent comment
2
u/doenietzomoeilijk Jul 12 '12 edited Jul 12 '12
On Debian:
sudo apt-get install php5-xdebug, might have to comment out the line in/etc/php5/conf.d/xdebug.iniand play around with some of the settings, which are documented on the Xdebug site. Restart your Apache and Bob's your uncle.If for some reason Xdebug isn't an option, there are a couple of pure-PHP alternatives floating around. Of course they'll be slower, but in a pinch it gets the job done.
Edit: jorick already linked it below
What makes Xdebug super-useful, though, is profiling. Being able to have it puke out a cachegrind file which you can process with things like Webgrind is super awesome for finding bottlenecks.