In this article, you will learn how to get the contents of the buffer which is currently at the top of the stack. The ob_get_contents() function in PHP returns the contents of the topmost output buffer.
what is the syntax of the OB_GET_CONTENTS() function in php?
ob_get_contents();
examples of the OB_GET_CONTENTS() function
Example 1. In this example, we store the contents of an output buffer in a variable.
<?php
ob_start();
echo "Hello World!";
$contents = ob_get_contents();
ob_end_clean();
echo "The contents of the buffer are: ";
echo $contents;
?>