title: PHP - how to stream content with Transfer-Encoding: chunked
body: <p>I'm trying to implement a simple stream test using php. with the following code I can see the response is being streamed - using firebug net tab.</p>
  
  <p>However the content does not get rendered until the response is done.
  What am I missing? </p>
  
  <pre><code>header('Content-Encoding: chunked');
  header('Transfer-Encoding: chunked');
  header('Content-Type: text/html');
  header('Connection: keep-alive');
  flush();
  ob_flush();
  
  for ($i = 0; $i &lt; 100; $i++) {
      dump_chunk('&lt;script type="text/javascript"&gt;console.log(' . $i . ')&lt;/script&gt;');
      flush();
      ob_flush();
      sleep(1);
  }
  
  function dump_chunk($chunk) {
      echo sprintf("%x\r\n", strlen($chunk));
      echo $chunk;
      echo "\r\n";
  }
  </code></pre>