我有一个应该是无限函数的函数,但是当我启动它时,它一直在加载。在这种情况下,他一直在 70-79 秒左右,而我已指定 21 秒set_time_limit
。
当我开始时它什么也没做,当这 75 秒完成时,它突然显示 8 倍的日期差异。一次全部。我希望它每 1 秒显示一次我的文本,并且不会滞后 1 小时,我下面的所有值都低于我上面所说的数字,因为我认为 1 秒可能会快,但它仍然滞后 10 秒
set_time_limit (21);
// 21 seconds until its done should become an hour later
// this was to test
$x=1;
$startTime = time();
$timeout = 10; //timeout in seconds
for ($i=0;;$i++)
{
if(time() > $startTime + ($x * $timeout)) {
$x++;
$today=date('d-m-Y H:i:s');
echo "it's now: ". $today . "</br>";
$newyear = date('d-m-Y H:i:s', mktime(0, 0, 0, 01, 01, 2013));
$difference=get_datediff_string($vandaag,$nieuwjaar);
// get_datediff_string() is defined somewhere below,
// but wasn't worth to show it.
echo "it is $difference untill newyear";
}
}