08 Feb
by: Matt in Development, PHP
tags: ob_flush, ob_implicit_flush, php
I write a lot of administrative scripts that have rather long execution times. Often it's desirable to be able to monitor the progress of the script in the browser, in realtime. By default I have my PHP installation setup with gzip output buffering enabled. This reduces the size of data transmitted to the client but also (obviously) buffers the output.
The PHP manual states that calling ob_implicit_flush(); "...will turn implicit flushing on or off. Implicit flushing will result in a flush operation after every output call, so that explicit calls to flush() will no longer be needed.". In my experience this doesn't actually happen.
The answer is simple. After every portion of output (whether it be nested html, echo, print - whatever) simply call ob_flush();.
Related posts:
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.