ob_get_flush
Flush the output buffer, return it as a string and close the output buffer
The ob_get_flush()
function outputs the content of the top-level output buffer, returns the content, and deletes the buffer. The output may be captured by another output buffer, or, if there is no other output buffer, sent directly to the browser.
Store the contents of the output buffer in a variable:
<?php ob_start ( ) ; echo "Hello World!" ; $contents = ob_get_flush ( ) ; echo "<br>" ; echo "The content of the buffer is:" ; echo $contents ; ?>
Try it yourself
ob_get_flush ( ) ;