PHP ob_gzhandler() Function

PHP ob_get_level() Function
PHP ob_implicit_flush() Function

In this article, you will learn how to compress the data passed in the output buffer in PHP. The OB_GZHANDLER() function in PHP is intended to be passed as a callback to ob_start(). It compresses the contents of the output buffer using a compression algorithm that is supported by the browser and returns the compressed content. It also sends an HTTP header indicating which compression algorithm was used.

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

ob_start("ob_gzhandler"); // when using callback function for ob_start()
ob_gzhandler(buffer, phase); // when using on its on
ParameterDescription
bufferThe contents of the output buffer
phaseA bitmask which may have any number of the following flags:
PHP_OUTPUT_HANDLER_START – If the output buffer was just created
PHP_OUTPUT_HANDLER_FLUSH – If the output buffer is currently being flushed
PHP_OUTPUT_HANDLER_FINAL – If the output buffer will be deleted right after this operation
PHP OB_GZHANDLER() method

examples of the OB_GZHANDLER() function

Example 1. In this example, we add gzip compression to a page.

<?php
ob_start("ob_gzhandler");
echo "Hello World!";
?>
PHP ob_get_level() Function
PHP ob_implicit_flush() Function
en English
X
Scroll to Top