ob_get_contents()
ob_get_contents() — Return the contents of the output buffer.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
ob_get_contents(): string|false
Parameters
This function takes no parameters.
Return value
This will return the contents of the output buffer or false, if output buffering isn't active.
Example
A runnable snippet:
ob_start(); echo "Hello "; $out1 = ob_get_contents(); echo "World"; $out2 = ob_get_contents(); ob_end_clean(); var_dump($out1, $out2);
Output:
string(6) "Hello " string(11) "Hello World"
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page ob_get_contents() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.