First, PHP never "just white pages". When you get a blank screen, that means PHP's execution has halted fro some reason. However, unless your server has been configured to not log errors, the PHP error log or the Magento exception log should have an error for you.
As far as your specific problem goes, many of Magento's objects contain reference to a large amount of information —?and sometimes the references are circular. PHP's var_dump
and print_r
functions will blindly follow these circular references and attempt to print everything out. This eventually leads to PHP using more memory than is allowed by the memory_limit
ini setting, and execution halts.
Most PHP professionals use the xDebug extension to work around this. The xDebug extension has a modified var_dump
that will limit the amount of information dumped, which prevents the above memory limit problems. The xdebug.var_display_max_children
, xdebug.var_display_max_data
, and xdebug.var_display_max_depth
ini settings are the ones you'll want to tweak if xDebug's still not helping with the memory limit problem. (some PHP distributions have these set too high initially)
If that's not a possibility, a little caution with your var_dump
's can still help.
Use this to figure out the variable type
var_dump(get_class($thing));
If it's a Magento object, use this to see its data keys
var_dump(array_keys($thing->getData()));
And then output individual data members with
var_dump($thing->getData('key_name'));
var_dump($thing->getKeyName()));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…