❮ PHP Output Control Functions
Add gzip compression to a page:
<?php
ob_start("ob_gzhandler");
echo "Hello World!";
?>
Try it Yourself »
This function 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.
When used as a callback for ob_start()
:
ob_start("ob_gzhandler");
When used on its own:
ob_gzhandler(buffer, phase);
Parameter | Description |
---|---|
buffer | The contents of the output buffer |
phase | A 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 |
Return Value: | Returns a string containing the compressed contents |
---|---|
PHP Version: | 4.0.4+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!