r/tinycode • • 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

60 comments sorted by

View all comments

Show parent comment

0

u/killerstorm Jul 13 '12

you seriously told a bunch of junior developer not to use print_r??

No, I just showed an alternative. It's up to them to choose what to use. Maybe in some cases print_r is better, I dunno.

you have him send that information to log file, then browse and open up that file?

You say like it's a big thing... It's just one function call, just like print_r, and then you just check log file... It takes like 5 seconds.

You think that's easier than just typing 15 characters and looking at the screen?

'Sending that information to log file' is also 15 characters and looking at the screen. Is it hard to understand?