❮ PHP Output Control Functions
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 »
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().
ob_get_level();
Return Value: | Returns an integer indicating how many output buffers are on the stack |
---|---|
PHP Version: | 4.2+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!