Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何处理PHP7.1(PHP-FPM+;NGINX)中的PHP致命错误?_Php_Nginx - Fatal编程技术网

如何处理PHP7.1(PHP-FPM+;NGINX)中的PHP致命错误?

如何处理PHP7.1(PHP-FPM+;NGINX)中的PHP致命错误?,php,nginx,Php,Nginx,以下是我的NGINX配置: error_page 500 502 503 504 /custom_50x.html; location = /custom_50x.html { root /usr/share/nginx/html; internal; } 但是,致命错误返回时响应为200。因此,在NGINX中未捕获该病毒 我试过: try { // Codes that creates Fatal Error here } catch (Error $e) { throw new E

以下是我的NGINX配置:

error_page 500 502 503 504 /custom_50x.html;
location = /custom_50x.html {
root /usr/share/nginx/html;
    internal;
}
但是,致命错误返回时响应为200。因此,在NGINX中未捕获该病毒

我试过:

try { // Codes that creates Fatal Error here }
catch (Error $e) { throw new Exception('Basically trying to convert Fatal Error into Exception'); } 
然而,上述代码并不稳定。有时,它返回的响应代码是500(这是我想要的),有时它返回的响应代码仍然是200

发生致命错误的原因是web应用程序试图一次性获取100000个对象/行


如何从NGINX传递PHP的致命错误?

您最好花时间研究如何优化代码,而不是捕获错误。您是否需要100000行,是否可以对其进行部分处理,是否可以使用数据库来限制数据?@NigelRen也许OP有意捕获该错误,以用于进一步的工作/错误处理程序功能?所讨论的错误是否总是内存不足错误?当内存不足时,您可能无法创建新对象(如
新异常
@Justinas),但我认为有必要询问解决问题的其他方法。@Karsten Koop我不确定这是否是内存不足错误。但是F致命错误(如屏幕截图所示)是
允许的内存大小…耗尽了…
。整个操作大约需要1 GB内存。