PHP Function Reference

PHP ob_get_status() Function



The PHP ob_get_status() function returns status information on either the top level output buffer or all active output buffer levels if full_status is set to true.

Syntax

ob_get_status(full_status)

Parameters

full_status Optional. If set to true, the function returns all active output buffer levels. If false or not set, only the top level output buffer is returned.

Return Value

If called without the full_status parameter or with full_status = false, the function returns status information on the top level output buffer. If called with full_status = true an array with one element for each active output buffer level is returned.

Example: ob_get_status() example

The example below shows the usage of ob_get_status() function.

<?php
//adding first output buffer
ob_start();

//adding second output buffer
ob_start();

//adding third output buffer
ob_start();

//getting status information on 
//the top level output
print_r(ob_get_status());
?>

The output of the above code will be:

Array
(
    [name] => default output handler
    [type] => 0
    [flags] => 112
    [level] => 2
    [chunk_size] => 0
    [buffer_size] => 16384
    [buffer_used] => 0
)

Example: using full_status parameter

By setting full_status=true, all active output buffer levels are returned. Consider the example below:

<?php
//adding first output buffer
ob_start();

//adding second output buffer
ob_start();

//adding third output buffer
ob_start();

//getting status information on 
//the top level output
print_r(ob_get_status(true));
?>

The output of the above code will be:

Array
(
    [0] => Array
        (
            [name] => default output handler
            [type] => 0
            [flags] => 112
            [level] => 0
            [chunk_size] => 0
            [buffer_size] => 16384
            [buffer_used] => 0
        )

    [1] => Array
        (
            [name] => default output handler
            [type] => 0
            [flags] => 112
            [level] => 1
            [chunk_size] => 0
            [buffer_size] => 16384
            [buffer_used] => 0
        )

    [2] => Array
        (
            [name] => default output handler
            [type] => 0
            [flags] => 112
            [level] => 2
            [chunk_size] => 0
            [buffer_size] => 16384
            [buffer_used] => 0
        )

)

❮ PHP Output Control Reference