Example
Store the contents of an output buffer in a variable:
html
<?php
ob_start();
echo "Hello World!";
$contents =
ob_get_contents();
ob_end_clean();
echo "The contents of the buffer
are: ";
echo $contents;
?>
Definition and Usage
The ob_get_contents() function returns the contents of the topmost output buffer.
Syntax
text
ob_get_contents();
Technical Details
| Return Value: | Returns a string containing the contents of the buffer |
|---|---|
| PHP Version: | 4.3+ |