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
    }
} 

它会在 运行 进入你的致命错误时被调用。