Using drupal_set_message() for quick debugging

This may be obvious and elementary to anyone who’s been developing with Drupal for a long time, but I recently discovered a reliable way to output information (specifically the contents of arrays and objects) during development.

Even the most novice PHP developer quickly realizes that outputting the contents of variables (with echo()), and arrays and objects (with print_r()) is useful.  These of course, work in Drupal as well, but with the many different contexts (modules, blocks, template files, etc) the output may not always show in a helpful location (like say, somewhere where it overflows and you get white text on a white background, or where it may otherwise blow your design apart.)

The quick tip of the day is to use:

drupal_set_message(”. print_r($something, TRUE) .”);