The PHP Function Ob_Get_Clean
PHP has a feature called output buffering. It helps improve performance by storing the HTML that gets echoed in a buffer until the last PHP statement is executed, and then sending it all at once to the browser. This can be used to avoid having to echo the same output several times in a row, which might slow down your web server.
To activate output buffering you need to call the ob_start() function. Then you can use the ob_get_clean() function to get the content of the buffer and remove it from the stack. The ob_get_clean() function essentially executes the ob_get_contents() and ob_end_clean() functions.
One of the clear drawbacks is that it gives the template everything it needs to work, including access to a database connection. This goes against the MVC philosophy of the view being as dumb as possible, and the controllers doing all the heavy lifting.
The other drawback is that it makes the MVC pattern difficult to implement, because you have to write a lot of code to handle all the different cases where you want to use ob_get_clean. I'd recommend using the extract function instead, which lets you return a value to your caller without having to do all the extra work. You can find more information about this function in the official PHP documentation, and you can also read a few real world examples of this function below. You can also practice your PHP skills by using the code section up on this page to do some ob_get_clean() examples yourself.