若脚本试图分配超过允许的内存,PHP将转储所有数据


PHP dump all data if script tries to allocate more than allowed memory

当脚本试图分配超出允许的内存时,有没有办法将脚本拥有的所有变量及其值转储到文件中?用于调试目的。

您可以使用以下代码:

register_shutdown_function('shutdownFunction');
function shutDownFunction() {
    if ($error['type'] == 1) {
        // do your stuff here
    }
} 

当遇到致命错误时,将调用它。