Reputation: 59
If I use time() in a loop, I always get the same values for 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;
}
?>
Upvotes: 2
Views: 776
Reputation: 56895
According to the docs for time()
, it
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 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).
Upvotes: 3