0
在我的開發服務器之前版本(CentOS 6.3,PHP 5.3)這工作得很好:發送擡頭執行結束
ignore_user_abort(true);
header('Location: http://test.hooshmarketing.com/tools/test/test_pretty_output.php');
//here a long script keeps executing in the background a few seconds
能正常工作太
ob_implicit_flush(true);
echo "foo"; //I see foo on the browser and...
sleep (15);
echo "bar"; //... about 15 seconds later I see bar on the browser
這
ob_start();
echo "foo"; //foo is written...
sleep(10);
ob_flush(); //...about 10 second later, foo is sent
echo "bar"; //bar is written...
sleep(10);
ob_end_flush(); //...about 10 second later, bar is sent
在我的承包商的生產服務器(bluehost PHP 5.2共享主機)上,這三個示例都不起作用。在腳本完成執行之前,什麼都不會發送到客戶端。我嘗試在腳本文件夾的php.ini文件中設置ini_set('output_buffering', '0')
和output_buffering = Off
,但沒有運氣。關於爲什麼會發生這種情況的任何想法?
它只覆蓋一個案例,而且它無法工作。我非常肯定所有的情況都是相關的:無論輸出如何,直到腳本結束都沒有輸出。而且,你確定嗎? http://php.net/ob_implicit_flush說:「在每次輸出調用後,隱式刷新都會導致刷新操作,所以不再需要對flush()的顯式調用。」) – NotGaeL
好吧,但仍然沒有解決問題:-((好奇地我不需要在我的開發服務器中不執行flush和ob_flush) – NotGaeL
是的,但是如果你正在使用ob_implicit_flush(true),你必須對每個打印/回顯使用ob_flush()。 。 – KumarA