Quick Tip: are you using pr()?

Tuesday 1 September 2009 12:43 , In , ,

pr() is a version of print_r() with <pre> tags wrapped around it. It will echo out your array in a human-readable format - without having to view source.

Why is this useful? Well, in the world of CakePHP, everything is an array and eventually you're going to have to do some debugging. Not only is pr() easier to type, it's

Why doesn't pr() work?



Have you set debug mode to zero?

Check your /app/config/core.php for this line:

Configure::write('debug', 0);


Change it to:

Configure::write('debug', 2);


And now you should get some nice debug output at the bottom of every page too.

3 comments:

What abou me? said...

the pr() is short enough indeed, but it's quite confusing if you are not working with CakePHP framework. That's why I have Macro in my editor which print print_r with pre's with pressing a key combination. and I used to with it. :)

3 September 2009 at 13:18
Unknown said...

Thanks for another great post. It will surely improve our coding practice. Keep sharing similar stuff.
php programming India

20 October 2010 at 23:38
jhon apps said...

what are the basics steps for learning PHP ?
if you can let me know so i will be thank full to you.

buy facebook app

14 February 2012 at 01:42

Post a Comment