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.


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

It helps me, hopefully it'll help you.

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

comments powered by Disqus