我使用以下代码:
/**
* Make the script run in the background
* return a message to the browser
* @param unknown_type $response
*/
function freeUserBrowser($response)
{
// let's free the user, but continue running the
// script in the background
ignore_user_abort(true);
header("Connection: close");
header("Content-Length: " . mb_strlen($response));
echo $response;
flush();
}
Run Code Online (Sandbox Code Playgroud)