如果我在循环中使用 time(),我总是会得到相同的时间值。但时间应该是一个函数而不是一个变量,所以我不明白问题是什么。
<?php
$i= 0;
while($i < 1000)
{
?>
<br>
<?php
echo time();
$i= $i +1;
}
?>
最佳答案
根据docs对于 time()
,它
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
强调我的。 while ($i < 1000)
可能会在一秒内执行,因此对于程序的任何给定运行,所有时间戳很可能都是相同的(但在下次运行时应该不同)。
关于php - PHP 中的 Time() 函数始终显示相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56605980/