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);
// 這裏的輸出不會立即發送給客戶端,而是寫入日誌或通過其他方式查看