Current Location: Home> Function Categories> ob_get_level

ob_get_level

Returns the nesting level of the output buffering mechanism
Name:ob_get_level
Category:Output buffer control
Programming Language:php
One-line Description:Returns a number indicating how many output buffers are on the stack.

Definition and usage

ob_get_level() function is used to indicate how many output buffers are on the current stack. PHP may be configured to automatically create an output buffer at the start of the script, which is why the buffer level may be 1 even if ob_start() is not called.

Example

Indicates how many output buffers are active:

 <?php
$buffer_count = ob_get_level ( ) ;
echo "Buffer level: $buffer_count .<br>" ;

// Add an output buffer
ob_start ( ) ;
$buffer_count = ob_get_level ( ) ;
echo "Buffer level: $buffer_count .<br>" ;

// Add another output buffer
ob_start ( ) ;
$buffer_count = ob_get_level ( ) ;
echo "Buffer level: $buffer_count .<br>" ;

// Close all buffers
ob_end_flush ( ) ;
ob_end_flush ( ) ;
?>

Try it yourself

grammar

 ob_get_level ( ) ;
Similar Functions
Popular Articles