Example
Indicate how many output buffers are active:
html
<?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();
?>
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
text
ob_get_level();
Technical Details
| Return Value: | Returns an integer indicating how many output buffers are on the stack |
|---|---|
| PHP Version: | 4.2+ |