ob_get_clean
Get the current buffer content and delete the current output buffer
ob_get_clean()
function returns the contents of the output buffer and then deletes the contents from the buffer.
Store the contents of the output buffer in a variable:
<?php ob_start ( ) ; echo "Hello World!" ; $contents = ob_get_clean ( ) ; echo "The content of the buffer is:" ; echo $contents ; ?>
Try it yourself
ob_get_clean ( ) ;