PHP ob_get_clean() Function
❮ PHP Output Control Functions
Example
Store the contents of an output buffer in a variable:
<?php
ob_start();
echo "Hello World!";
$contents = ob_get_clean();
echo "The contents of the buffer are: ";
echo $contents;
?>
Try it Yourself »
Definition and Usage
The ob_get_clean()
function returns the contents of the output buffer and then deletes the
contents from the buffer.
Syntax
ob_get_clean();
Technical Details
Return Value: | Returns a string containing the contents of the buffer |
---|---|
PHP Version: | 4.3+ |
❮ PHP Output Control Functions