ob_get_level()

ob_get_level() — Return the nesting level of the output buffering mechanism.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.2.0, 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_level(): int

Parameters

This function takes no parameters.

Return value

Returns the level of nested output buffering handlers or zero if output buffering is not active. The value for identical levels between ob_get_level() and ob_get_status() is off by one. For ob_get_level() the first level is 1. Whereas for ob_get_status() the first level is 0.

Example

The PHP manual ships no example for ob_get_level(); the signature and the parameter table above are the contract.

See also

ob_start(), ob_get_status(), ob_get_contents()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page ob_get_level() (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.