Debug magento with Zend_debug::dump

dump() is a static method defined in debug class under Zend. This one of the more stuffs I love in Magento. Because it helps me debug any variable or objects in simple ways. You can echo what ever you want, lets say, a simple variable, an array, an object, any complex data type and so on…


Zend_Debug::dump($var, $label = null, $echo = true);

The $var argument specifies the expression or variable about which the Zend_Debug::dump() method outputs information.

The $label parameter prepends the string provided before the output. Mostly we don’t use this parameter, but you can see its use when you dump values of same variable at different lines of code, that time only this $label field will help you to understand the corresponding results.

The $echo parameter is to make dump() function not to print the values if set to false. Regardless of the value of the $echo argument, the return value of this method contains the output.

In core php, the dump method is equivalent

echo “<pre>”;
echo “</pre>”;


But this function returns more formatted and readable result. Instead of writing three lines of code every time for debugging, we can now use a single line of code.  From now start using Zend_debug::dump() and your love towards Magento/Zend will be doubled for sure.