ob_start();
echo 'hello world';
$size_o = ob_get_length();
header("Content-Length: $size_o");
header('Connection: close');
header("HTTP/1.1 200 OK");
ob_end_flush();
if(ob_get_length()) {
ob_flush();
flush();
}
// 继续执行脚本的其余部分
sleep(10); // 假设这里是需要持续运行的代码
echo "脚本继续运行中...";
file_put_contents('test.log' , "脚本继续运行中..." . PHP_EOL, FILE_APPEND);
// 这里的输出不会立即发送给客户端,而是写入日志或通过其他方式查看