Welcome Guest, Not a member yet? Register   Sign In
Stream Output buffer

Here's a helper I created to do that:

//kill CI's buffered output and stream realtime
if ( ! function_exists('kill_buffer'))
function kill_buffer()
  $CI =& get_instance();
  //output any CI output up til now
  echo $CI->output->get_output();
  //output/wipe buffer and enable implcit flush
   //For some reason about 1kb needs to be sent before realtime output shows up.  Just send a bunch of spaces in a hidden div.
   echo '<div >' . str_repeat('&nbsp;', 170) . '</div>';

   //No headers beyond this point unless they are sent FIRST...

Depending on your usage, you might need to adjust the very last output (like you wouldn't want to output html to the CLI), but I use it in a browser so that's how I wrote it.

To test you could just do:
for ($x = 0; $x < 5; $x++)
  echo date('H:i:s') . '<br>';
should write the time in real time to the browser 5 times, 1 second apart.

Messages In This Thread
Stream Output buffer - by El Forum - 08-06-2014, 06:57 AM
Stream Output buffer - by El Forum - 08-06-2014, 12:04 PM

Theme © iAndrew 2016 - Forum software by © MyBB