Questions? Feedback? powered by Olark live chat software dpm() or dsm() - Which should you use? | Zyxware Technologies

Get a free quote now

dpm() or dsm() - Which should you use?

March 30, 2012 - 13:02

Drupal’s Devel module provides a wide range of functionalities that make a Drupal developer’s life much saner. Of these, the most useful one is the function dpm() which seems to have a twin clone - dsm().

For those who are unaware, dpm() is a highly useful function for neatly printing (pretty printing) arrays/objects etc in drupal. There is also a function dsm() in the devel module, which seems to do the same thing.

Then which is the correct one?

Quick Answer: Use dpm().

Here’s the long answer:
Drupal’s Devel module provides a wide range of functionalities that make a Drupal developer’s life much saner. Of these, the most useful one is the function dpm() which seems to have a twin clone - dsm().

For those who are unaware, dpm() is a highly useful function for neatly printing (pretty printing) arrays/objects etc in drupal. There is also a function dsm() in the devel module, which seems to do the same thing.

Then which is the correct one? The answer is, dpm().
dsm() is kept just for legacy sake. It just sits there in devel module and calls dpm() when invoked.

From devel.module:

// legacy function that was poorly named. use dpm() instead
// since the 'p' maps to 'print_r'

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

Post your comments / questions

You may also like