php 判断页面或图片是否经过gzip压缩的方法
(编辑:jimmy 日期: 2025/4/21 浏览:3 次 )
使用php判断页面或图片是否经过gzip压缩方法
1.使用get_headers
页面内容
<"htmlcode"><"color: #ff0000">2.使用curl
图片
上一篇:php 从指定数字中获取随机组合的简单方法(推荐)<"htmlcode"><"\r\n", "\r"); $header_str = str_replace($filter, PHP_EOL, $header_str); // 检查content-encoding preg_match('/Content-Encoding: (.*)\s/i', $header_str, $matches); if(isset($matches[1]) && $matches[1]=='gzip'){ return true; } } return false; } "color: #ff0000">测试结果:
当加上ob_gzhandler时,返回true,删除后返回false
以上这篇php 判断页面或图片是否经过gzip压缩的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
下一篇:通过php动态传数据到highcharts