Q:

PHP: while (time() < time()+2;){ echo "why does this not work ?"};

$zeit = time();
$zeit60 = time()+2;

while ($zeit < $zeit60){
sleep (1);
echo time();
}

why does this not work ?
Thanks for Answers!

A:

Your code will print the time every second... forever. Because the condition is essentially while x < x+2, which is of course true ∀ x ∈ ℝ
You probably should update the value of $zeit, so that after the time expires your loop will exit.
That said, unless you have particularly complex code, it may be sufficient to do the following:
$seconds = 2;
while($seconds) {
    sleep(1);
    echo time();
    $seconds--;
}

