简体   繁体   English

PHP中的Time()函数始终显示相同的值

[英]Time() Function in PHP always shows same value

If I use time() in a loop, I always get the same values for time. 如果我在循环中使用time(),那么我总是会得到相同的时间值。 But time should be a function and not a variable, so I dont understand what the problem is. 但是时间应该是一个函数而不是变量,所以我不明白问题出在哪里。

<?php

$i= 0;

while($i < 1000)
{
?>
 <br>
<?php
echo time();
$i= $i +1;
}

?> ?>

According to the docs for time() , it 根据文档 time() ,它

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). 返回自Unix纪元(1970年1月1日00:00:00 GMT)以来以单位的当前时间。

Emphasis mine. 强调我的。 while ($i < 1000) will likely execute in under a second, so all of the timestamps are quite likely to be the same for any given run of the program (but should be different on the next run). while ($i < 1000)可能会在一秒钟内执行,因此,对于任何给定的程序运行,所有时间戳很可能都相同(但在下一次运行中应该不同)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM