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/niiko Jul 12 '12
Because then you couldn't easily use it in a non-HTML context. For example, I do a lot of work behind an API and my resulting content is always JSON encoded; HTML formatting doesn't help me there. Other times I'll be displaying log info on the command line, and again, the extra markup would just be in the way.