Flush Buffers in PHP

Here is a quick snippet that I use all the time when my PHP code is generating output for a long time and I need to see it as it's happening.

/content/images/uploads/php.png

function flush_buffers() {  
    echo(str_pad("", 2048, " ")); // Fix Chrome buffers.
    ob_end_flush();
    @ob_flush(); // Suppress potential errors
    flush();
    ob_start();
}

It helps me, hopefully it'll help you.

Remember, don't call this too often, unless you absolutely must.


comments powered by Disqus