PHP无限循环延迟[重复]

This question already has an answer here:

I am trying to make a PHP loop with delay between the loop this doens't work

<?php
$i=0;
while(true) {
    $i++;
    echo $i;
    sleep(1);
}
?>

I am trying to get this as an output:

1
[wait 1 second]

2
[wait 1 second]

3
[wait 1 second]

4
[wait 1 second]

5
[wait 1 second]

6
[wait 1 second]

...
</div>

Try using flush and ob_flush to send the output to the browser before the script is completed:

<?php
header( 'Content-type: text/html; charset=utf-8' );
$i=0;
while(true) {
  $i++;
  echo $i;
  flush();
  ob_flush();
  sleep(1);
}
?>