ob_flush in php

ob_flush — Flush (send) the output buffer

ob_flush(): bool

This function will send the contents of the output buffer (if any). If you want to further process the buffer’s contents you have to call ob_get_contents() before ob_flush() as the buffer contents are discarded after ob_flush() is called.

ob_flush Example

<?php
header( 'Content-type: text/html; charset=utf-8' );
echo 'Begin ...<br />';
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo $i . '<br />';
    flush();
    ob_flush();
    sleep(1);
}
echo 'End ...<br />';
?>

Leave a Comment