Current Location: Home> Function Categories> ob_get_contents

ob_get_contents

Returns the contents of the output buffer
Name:ob_get_contents
Category:Output buffer control
Programming Language:php
One-line Description:Returns the contents of the top-most output buffer.

Definition and usage

ob_get_contents() function returns the contents of the top-most output buffer.

Example

Store the contents of the output buffer in a variable:

 <?php
ob_start ( ) ;
echo "Hello World!" ;
$contents = ob_get_contents ( ) ;
ob_end_clean ( ) ;

echo "The content of the buffer is:" ;
echo $contents ;
?>

Try it yourself

grammar

 ob_get_contents ( ) ;
Similar Functions