title: How to get realtime output from php as it happens?
body: <p>How to get real-time output from php as it happens ? without storing all in memory/buffer and echoing all at once to the browser ?</p>
  
  <p>if i create a realtime-echo.php</p>
  
  <pre><code>&lt;?php
  for($i = 0; $i &lt; 10; $i++)
  {
  echo $i;
  sleep(1);
  }
  </code></pre>
  
  <p>and access it from Internet browser it gives following output , after 9-10 seconds.</p>
  
  <pre><code>0123456789
  </code></pre>
  
  <p>but what i am willing the output to be is, when i access the php file from my browser it should give</p>
  
  <p>0</p>
  
  <p>then wait 1 second then add "1" after the "0" 
  then wait 1 second then add "2" after the "1"
  and so on.</p>
  
  <p>idk what its called like animation/real-time .</p>
  
  <p>How do  achieve this ?</p>
  
  <p>I am working on the project where i need the constant output as it happens so i can keep eye on whats happening and where its going.</p>
  
  <p>Thanks</p>