I am trying to send a response data to the client from a function and continue the execution. I followed the below code
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();
}
Got the code from the question
continue processing php after sending http response
What I am getting is a 200 ok response only but not the data which I echoed.
I need to get the response data too. I am using php7.1. Is there any difference of use between php5 and 7?
Please help
All you need to do is
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With