print_r() - Print Variable Contents

By Hawkee on Aug 12, 2004

I use this almost every day. It's one of the most useful PHP debugging tools. You can print all of the contents of a variable (class, array or scalar) to get an idea of how the structure looks.

<?php
    print "<pre>";
    print_r($variable);
    print "</pre>";
?>

Comments

Sign in to comment.
sean   -  Oct 02, 2008

another way of doing this is with printf();

printf('<pre>%s</pre>', print_r($variable, true));
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.