print_r in drupal_set_message

Description

This example will print our human readable information about the $_SESSION inside a drupal_set_message. You can replace the $_SESSION with any other variable or array (or object).

Snippet

drupal_set_message(print_r($_SESSION,true));

Comments

Enhancement

This version makes the output easier to read:

drupal_set_message('<pre>'. print_r($_SESSION, true) .'</pre>');

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options