Using the PHP Functions That Work With Output Buffering
PHP has a great feature for its scripts called output buffering. It allows you to temporarily hold on the content of a script until you want to send it to the browser. This can help save CPU power on a busy server or light frontends. It also can be very useful when working with multiple requests or if you need to do something in a loop and don't want to have to call the function every time.
There are many other functions to work with the buffering but one very handy one is ob_end_flush. This function sends what is in the buffer (if any) and then turns off output buffering at that level. It is important to note that you should call ob_get_contents() before ob_end_flush() because once the buffer is sent the contents are discarded.
Another handy function is ob_list_handlers() which can be used to return an array of all the handlers that are active at the current output buffer level. This can be helpful for figuring out which part of the script is sending data to the browser. There is also ob_get_status() which is useful for getting information about the current output buffering status. This can be done for the top level buffer or all levels. Combining these can give you a lot of control over the buffering and how it works with your scripts. It is really cool to see the effects of these and how they interact together.