我遇到了echo/print返回大量數據的問題。該響應被打破,如下:大的打印/回聲中斷http響應
- 數據的端
- HTTP響應報頭中體
我運行下面的腳本來我的瀏覽器來複制數據的開始印刷問題:
<?php
// Make a large array of strings
for($i=0;$i<10000;$i++)
{
$arr[] = "testing this string becuase it is must longer than all the rest to see if we can replicate the problem. testing this string becuase it is must longer than all the rest to see if we can replicate the problem. testing this string becuase it is must longer than all the rest to see if we can replicate the problem.";
}
// Create one large string from array
$var = implode("-",$arr);
// Set HTTP headers to ensure we are not 'chunking' response
header('Content-Length: '.strlen($var));
header('Content-type: text/html');
// Print response
echo $var;
?>
這裏發生了什麼?
其他人可以試試嗎?
我試過添加ob_end_flush();在我的腳本結尾處,問題是一樣的。 –
不是最後,在頭文件和'echo'語句之間。 – Rijk
試過了,不幸的是同樣的問題 –