6月
5
2007
分類:
最近更新:
2007-06-05
TWPUG問答 - 如何反覆計時執行
she96965 問: 我想要過三秒後執行一次函數,再過三秒在執行一次,一直反覆一直反覆
。
答: 用 sleep() 。另一方面, PHP 有一個最大執行時間的限制,故尚須配合 set_time_limit() 重置最大執行時間的計時。
<?php
echo date('h:i:s') . "\n";
while (true) {
set_time_limit(5); //reset execute time limit, greater than sleep time.
sleep(3);
echo date('h:i:s') . "\n";
}
?>
樂多舊網址: http://blog.roodo.com/rocksaying/archives/3407615.html
樂多舊回應