Output buffering is a mechanism for controlling how much output data
(excluding headers and cookies) PHP should keep internally before
pushing that data to the client. If your application's output exceeds
this setting, PHP will send that data in chunks of roughly the size
you specify. Turning on this setting and managing its maximum buffer
size can yield some interesting side-effects depending on your
application and web server. You may be able to send headers and
cookies after you've already sent output through print or echo. You
also may see performance benefits if your server is emitting less
packets due to buffered output versus PHP streaming the output as it
gets it. On production servers, 4096 bytes is a good setting for
performance reasons.
Note: Output buffering can also be controlled via Output Buffering Control
functions.
php.ini Possible Values:
On = Enabled and buffer is unlimited. (Use with caution)
Off = Disabled
Integer = Enables the buffer and sets its maximum size in bytes.
eg: output_buffering = Off
Note: This directive is hardcoded to Off for the CLI SAPI
http://php.net/output-buffering
A Working example if output_buffering is set to 4096
<?php
ob_start();
// Output string to overflow browser php.ini output_buffering setting.
echo str_repeat(PHP_EOL, 4097);
for ($i=0; $i<5; $i++) {
echo PHP_EOL.$i;
ob_flush();
flush();
sleep(1);
}
ob_end_flush();
?>