Top

print_r() - Print Variable Contents


PHP Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  5.0 (of 2 scores)
Date Added  Aug 12, 2004
Last Updated  Sep 04, 2008
Tags  printr 

Introduction

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.

Grab the Code

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

Comments

  (2)  RSS
BackoffJackson
Comments: 57
 
PHP Snippet:  print_r() - Print Variable Contents
Posted on Jan 30, 2007 11:44 pm
Has a purpose, but that is about it.
sean
Comments: 109
 
PHP Snippet:  print_r() - Print Variable Contents
Posted on Oct 2, 2008 7:49 am
another way of doing this is with printf();
Code:
printf('<pre>%s</pre>', print_r($variable, true));

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom