ob_get_length()
ob_get_length() — Return the length of the output buffer.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.0.2, 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.
What it does
This will return the length of the contents in the output buffer, in bytes.
Signature
ob_get_length(): int|false
Parameters
This function takes no parameters.
Return value
Returns the length of the output buffer contents, in bytes, or false if no buffering is active.
Example
A runnable snippet:
ob_start(); echo "Hello "; $len1 = ob_get_length(); echo "World"; $len2 = ob_get_length(); ob_end_clean(); echo $len1 . ", " . $len2;
Output:
6, 11
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page ob_get_length() (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.