Replacement for print_r
Wednesday, 9 September, 2009 - 20:15
How many times have you done the good old print_r($var); just to find out what’s in the variable?
I have been using the devel modules for age’s but it still surprises me what you can find if you just look at some code every now and then.
The devel module comes with a few great functions which you could use instead print_r();
kpr() function
Example:
kpr($node);
Output:

dpr() function
Example:
dpr($node);
Output:

dvr() function
Example:
dvr($node);
Output:

Looks better then the print_r output. If you know a better way leave a comment and let us know.
Category:
Comments
Another cool thing, which
Another cool thing, which does the devel module is dd($array);
This outputs the data into tmp/drupal_debug.txt, where you can get the data by using tail -f drupal_debug.txt.
Other replacements
You can use also dsm() from Devel module which will show exactly the same output as kpr().
var_export
i still consider var_export the most usable of them all, just pick up the output, drop it in a script and you can play with it. that's something only var_export output does.
Firebug + Drupal for Firebug
Firebug + Drupal for Firebug module/extension