This one is crazy with magento because sometimes it works and sometimes it just shows blank page. Once it gave me a real hard time. Finally found solution somewhere.
//I just had to do was add
//on the object that i wanted to print as:
//e.g. if i had
$_cart = Mage::getModel('checkout/cart');
//to use print_r or var_dump, i needed to do