PHP Function Ob_Start
The php function ob_start helps to enable the buffering of specific output before any type of echoing or any HTML in your PHP scripts. This helps in increasing the performance of your web application as PHP is an interpreted programming language and each statement is executed one after the other. So PHP tends to send the HTML to the web browsers in chunks which reduces the performance. To overcome this problem PHP programming language introduces the output buffering.
Buffers are stackable, which means you may call ob_start() while another ob_start() is active as long as ob_end_flush() is called before the end of your script. If multiple output callback functions are active, output is filtered sequentially through them in their nesting order. If the ob_end_flush() function is not called, original output is sent to the browser as is.
In the above script, three string values have been sent to the buffer. The callback function convert_upper() is used to change the content of the output buffer into uppercase. The output of ob_get_contents() will be stored into the three variables and when ob_end_flush() will be called, the contents of these variable will be sent to the browser. The var_dump() function is used to dumb the contents of these three variables.
PHP is the OG of programming for the web and WordPress, built in PHP, powers 25% of the internet at large. But it’s not just a little venerable language that’s going away any time soon – the php function ob_start is an extremely powerful tool for anyone who uses PHP to build web applications.