27

What are the differences between dpm() and dsm()?

5 Answers 5

35

dpm() prints a variable to the ‘message’ area of the page using drupal_set_message(). The output and compact and less likely to break the layout of your page.

From the devel docs:

A note from the devel module: dsm() is a legacy function that was poorly named; use dpm() instead, since the 'p' maps to 'print_r'.

I think we should trust the devel folks on that one.

6

dsm() is legacy function. It's a call to dpm() as it is, so you should use dpm().

3

drupal_set_message() is a Drupal core function that sets messages to be output on the next page view. drupal_print_message() is, I believe (based on the examples I found in Google), something people occasionally say by accident when they actually mean drupal_set_message(), but not a real function.

Note: there is a dpm() function in the Devel module, which is short for "drupal print message" that outputs variables for development debugging.

1
  • Edited my question for clarification. I am using devel. Commented Oct 28, 2010 at 22:33
3

They're all the same, check how dsm() is defined (one is calling another):

function dsm($input, $name = NULL) {
  return dpm($input, $name);
}

So the main one which should be used is dpm(), as dsm() is deprecated.

0

Devel Demo is a good drupal module that demonstrate the most of the debugging functions provided by devel module and here is a good post which gives a brief overview of those functions.

1
  • you need to include the relevant information in your answer, not just link to offsite resources.
    – DrCord
    Commented Jan 8, 2016 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.