In PHP, ob_get_status() returns an array of status details about the active output buffer, or about every active buffer when full status is requested.
With the default false, you get one associative array for the top buffer (name, type, flags, level, chunk_size, buffer_size, buffer_used). With true, you get a numeric list of those arrays, one per nesting level. With no buffering, you get an empty array.
Syntax
Call ob_get_status() with the values you need. Start with this line.
PHP
$info = ob_get_status();
Call
What it does
ob_get_status()
Status array for the top active buffer, or [] if none.
ob_get_status(true)
List of status arrays for every nested buffer.
ob_get_status()['buffer_used']
Bytes currently stored, same idea as ob_get_length().
The "level" key inside the status array is zero-based. The first buffer has status level 0, while ob_get_level() reports 1 for that same buffer. "name" is usually "default output handler" for a plain ob_start().
Library declarations
PHP
ob_get_status(bool $full_status = false): array
Parameters
Parameter
Description
full_status
Optional. false (default) returns only the top buffer. true returns status for every active nesting level.
Return Value
Return Value
Description
array
One status array for the top buffer, a list of status arrays when full_status is true, or an empty array when buffering is off.
PHP Examples
Example 1 — Read Top Buffer Status
Start a buffer, echo a short string, and print a few useful status fields.