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

hi all, i have a long task running ( ftp uploads )
and i need enable output flushing how i can do it with CI ?

im trying with ob_flush (tried also to se implicit flush ) but without success

any one have a solution?

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.

Theme © iAndrew 2016 - Forum software by © MyBB