Normally, the output starts as soon as your first "echo" comes or first non-PHP content. Once output starts, we cannot send headers . So to tackle this we use output buffering we is disabled by default.
To create a new output buffer and start writing it, we call ob_start(). There are two ways to end a buffer :-
It ends the buffer and sends all data to output
It ends the buffer without sending it to output.
Consider the following script:
echo "Hello One!\n";
echo "Hello Two!\n";
echo "Hello Three!\n";
Output : Hello One! Hello Three!
This script will output "Hello One" because the first text is placed into a buffer then flushed with ob_end_flush().
The "Hello Two" will not be printed out, although it is echoed, because it is placed into a buffer which is cleaned using ob_end_clean() and not sent to output.
Finally, the script will print out "Hello Three" because PHP automatically flushes output buffers when it reaches at the end of a script.