PHP ob_get_contents() Function

P
PHP ob_get_clean() Function
PHP ob_get_flush() Function

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;
?>
PHP ob_get_clean() Function
PHP ob_get_flush() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z