I am learning advanced theming for which I am using Devel Module kpr() and dsm() functions to print the arrays on the page for finding variables. So I want to know, What is the main difference between kpr() and dsm() functions? And which one is the best for which condition.
In Devel there are various formatters you can use to dump variables. But the main difference of
dsm() is, that it uses
drupal_set_message(), which displays the output in the message array via a session, so that the information is preserved between different requests of the same user. This is helpful for debugging code, which doesn't result in a html page to display a normal var dump, for example a form submit. The disadvantage is, that
dsm() sometimes produces the output asynchron, not when you expect it, which can lead to false conclusions.