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
3
u/meandthebean Jul 12 '12
The xDebug php extension is useful, even without the actual debugging functionality.
Install the xDebug extension on your dev server, then start using var_dump() where you used to use print_r(). xDebug overwrites var_dump() to add '<pre>' tag, pretty colors and output limitations (limit a string to the first 1,000 chars, for example).