Home >Backend Development >PHP Tutorial >PHP detects whether the server supports gzip code_PHP tutorial
This article will introduce you to a PHP test server that supports gzip code. Friends who need to know more can refer to it.
To check whether gzip is supported, you can use the function_exists function to determine whether your php environment supports ob_gzhandler. If it supports gzip, it supports gzip.
Write a function myself
The code is as follows
|
Copy code |
||||
if(extension_loaded('zlib')) {ob_start('ob_gzhandler');} header('Content -type: text/html;charset=utf-8'); echo 'If you can see this line of text, it means that your server supports gzip. If it cannot be displayed, it does not support it. '; if(extension_loaded('zlib')) {ob_end_flush();}
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:A simple word guessing game_PHP tutorialNext article:A simple word guessing game_PHP tutorial Related articlesSee more |