2013-07-13 41 views
1

如何關閉連接並繼續在以下環境的背景上?php關閉連接並繼續在背景上

服務器:Microsoft-IIS/7.0

PHP支持:(運行爲FastCGI應用程序)

PHP版本:5.2.17

主持人:共享,CRON:NO

我嘗試了許多現有的解決方案,它在本地wamp服務器或PHP LINUX服務器上工作,但不在IIS中。

// buffer all upcoming output 
ob_start(); 
echo "Here's my awesome web page"; 

// get the size of the output 
$size = ob_get_length(); 

// send headers to tell the browser to close the connection 
header("Content-Length: $size"); 
header('Connection: close'); 

// flush all output 
@ob_end_flush(); 
@ob_flush(); 
@flush(); 

// close current session 
if (session_id()) session_write_close(); 

sleep(10); 

// DO SOME BACKGROUND WORK ... 

請幫忙。

感謝

+0

你的預期行爲是什麼 – DevZer0

+0

@ DevZer0更新了問題,我需要做一些後臺活動。 – Red

+0

很多事情都可能出錯,包括下游緩存和壓縮搞亂Content-Length。您標記了CodeIgniter;也增加了自己的緩衝層。如果有一種永不失敗的方式來實現這一點,我從來沒有見過。 (所以,如果你找到一個,請讓我知道!) – Jerry

回答