PHP7在发送响应后继续执行

PHP7在发送响应后继续执行,php,httpresponse,fastcgi,Php,Httpresponse,Fastcgi,我正在尝试从函数向客户端发送响应数据并继续执行。我遵循下面的代码 ignore_user_abort(true); set_time_limit(0); ob_start(); // do initial processing here echo $response; // send the response header('Connection: close'); header('Content-Length: '.ob_get_length()); ob_end_flush(); ob_f

我正在尝试从函数向客户端发送响应数据并继续执行。我遵循下面的代码

ignore_user_abort(true);
set_time_limit(0);

ob_start();
// do initial processing here
echo $response; // send the response
header('Connection: close');
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
flush();
// check if fastcgi_finish_request is callable
if (is_callable('fastcgi_finish_request')) {
    fastcgi_finish_request();
}
从问题中得到了密码

我得到的只是一个200 ok的响应,而不是我回显的数据。

我也需要得到响应数据。我正在使用php7.1。php5和7的使用有什么不同吗

请帮助

您需要做的就是

set_time_limit(0);

echo $response; // send the response

// check if fastcgi_finish_request is callable
if (is_callable('fastcgi_finish_request')) {
    fastcgi_finish_request();
}

使用fastcgi_finish_request()@欧内斯塔斯坦克维奇乌斯你应该把它作为一个答案,并提到它的作用以及它为什么能解决OP的问题。@欧内斯塔斯坦克维奇乌斯,我忘了在我的问题中提到这一点。更新了问题。使用了
fastcgi\u finish\u请求
,但它也不起作用。