我有一個HTML頁面,它顯示了一個進度條,它逐步完成一個進程。它使用flush()將數據發送到瀏覽器。我試圖讓這個在Zend進程中工作,我通過專門發送頭文件,內容,然後用退出命令結束進程來短路。HTTP頭差異 - 遞增加載頁面
HTML頁面顯示正確(進度條步驟完成)。 Zend/PHP頁面只顯示完成的頁面(不是步驟)。我假設這是一個頭問題,因爲方法(flush())是相同的。
在Chrome中,對HTML頁面的標題出現爲:
HTTP/1.1 200 OK
Date: Fri, 27 Jul 2012 14:38:07 GMT
Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8r DAV/2 PHP/5.3.2
X-Powered-By: PHP/5.3.2
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
而對於在Zend/PHP頁面的標題出現爲:
HTTP/1.1 200 OK
Date: Fri, 27 Jul 2012 14:44:13 GMT
Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8r DAV/2 PHP/5.3.2
X-Powered-By: PHP/5.3.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-cache
Pragma: no-cache
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
唯一的報頭信息我在PHP米指定爲:
header('Content-Type: text/html; charset=utf-8');
我使用這個代碼從該頁面:http://w3shaman.com/article/php-progress-bar-script
任何幫助,將不勝感激。謝謝。
您是否嘗試過使用'ob_flush()'以及'flush()'? Zend可以激活輸出緩衝。 – Tchoupi 2012-07-27 15:11:48
要提煉@ MathieuImbert的觀點 - 你需要在調用'flush()'之前調用'ob_flush()'**。 – DaveRandom 2012-07-27 15:19:23
我以前試過,它沒有工作,但現在它是。我假設w3shaman.com中的方法是不同的。感謝您的修復。 – 2012-07-27 15:22:22