PHP ob_get_level() Function

P
PHP ob_get_length() Function
PHP ob_gzhandler() Function

In this article, you will learn how to count the output buffers currently in the stack in PHP. The ob_get_level() function in PHP 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().

what is the syntax of the OB_GET_LEVEL() function in php?

OB_GET_LEVEL();

examples of the OB_GET_LEVEL() function

Example 1. In this example, we 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();
?>
PHP ob_get_length() Function
PHP ob_gzhandler() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z