How do I var_dump data in the file controller and Model?

I tried: var_dump and die

and view source ... but it's not displayed


I rarely use var_dump or echo to the screen when programming Magento. I find it far better to use print_r in conjunction with the Magento logging function.

Add a line like this to your code -

Mage::log("this is my data -\n".print_r($model->debug(),true),1,"mylogfile.log",true);

This will dump the debug data for the model to a log file called mylogfile.log in the var/log directory under Magento's root. The final true parameter to the log function forced the logger to write regardless of Magento's logging setting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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