如何检查 PHP 是否启用了 gzip 压缩?

the*_*cat 5 php compression gzip

是否(function_exists('ob_gzhandler') && ini_get('zlib.output_compression'))足够?

我想检查主机是否在其中一个页面中提供压缩页面:)

Hea*_*ore 5

对于 PHP,他们会做得很好。

但是,如果您指的是将页面压缩回客户端,您还需要检查它是否在 apache 中启用(假设您使用 apache,您将需要 mod_gzip.c 或 mod_deflate.c 模块)。

例如: # httpd -l(apache 2)

我还看到提到需要在过去实现 .htaccess 覆盖:

#compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
Run Code Online (Sandbox Code Playgroud)