PHP ob_get_level() Function
❮ PHP Output Control Functions
Example
Indicate 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 »
Definition and Usage
The ob_get_level()
function indicates how many output buffers are currently on the stack. PHP may be configured to
automatically create an output buffer when the script begins, which is why the buffer level
may be 1 without calling ob_start().
Syntax
ob_get_level();
Technical Details
Return Value: | Returns an integer indicating how many output buffers are on the stack |
---|---|
PHP Version: | 4.2+ |
❮ PHP Output Control Functions
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.