An alternative to print_r in Drupal

How many times do we use a quick print_r to see what's in $node or $result or anything else? When coding modules , it's not very easy to output data structures to the screen unless you do a print_r($node) and view the source code. or do it like this :

[php]<pre><?php print_r($node); ?></pre>[/php]

Here's a clean and simple way you can output such data on screen. If you have the developer module enable (devel), use the dsm() (drupal_set_message) function.

Example :

[php]<?php dsm($node); ?>[/php]

Sample output :

It uses krumo to display the content.

Comments

Hey that's super cool!

Add new comment