我需要在PHP中進行應用程序,它將在while循環中工作,並監聽連接,如果我發送停止信號,它將在while循環中停止。當「while循環」正在進行時,PHP偵聽按鈕/連接
例如:
<?PHP
set_time_limit(0);
$i=0;
while ($i <= 2000){
// Listen for connection = Kill signal
// For example:
// if signal is received{
// break;
// }
$i++; // Count
usleep(2000);
}
?>
所以,如果我有停止按鈕的Web界面,我想能夠停止while循環,當我點擊該停止按鈕。
這是可能的嗎?你最有可能的最佳方式是使用js,因爲它是客戶端,php是服務器端。 – Class
不可能。 php代碼在**發送之前在服務器**上進行評估。 – fragmentedreality
類似:http://stackoverflow.com/questions/11705357/how-to-listen-muliple-tcp-streams-continously-by-stream-get-contents 可能做到這樣嗎? – xZero