用PHP判断服务器是否支持GZIP

<p >用PHP判断服务器是否支持GZIP</p> <p ><img alt="" src="/up_pic/201211/20121107081939.jpg" /></p> <p >&lt;?php<br /> $fp = stream_socket_client ('tcp://127.0.0.1:80', $errno , $errstr , 10 );<span class="Apple-converted-space"></span><br /> if (! $fp ) {<span class="Apple-converted-space"></span><br /> echo &quot; $errstr ( $errno )&lt;br /&gt;n&quot; ;<span class="Apple-converted-space"></span><br /> } else {<span class="Apple-converted-space"></span><br /> fwrite ( $fp , &quot;HEAD /?gzip HTTP/1.1<br /> Host: xxxx.com<br /> Accept-Encoding:gzip, deflate</p> <p >&quot; );<span class="Apple-converted-space"></span><br /> while (! feof ( $fp )) {<span class="Apple-converted-space"></span><br /> echo fgets ( $fp , 1024 );<span class="Apple-converted-space"></span><br /> }<span class="Apple-converted-space"></span><br /> fclose ( $fp );<span class="Apple-converted-space"></span><br /> }<span class="Apple-converted-space"></span><br /> ?&gt;</p> <p ></p> <p >输出信息看见<span ><span ><span >GZIP</span></span></span>字样就表示已经支持了。</p>
T:0.005827s,M:204.8 KB
返回顶部 留言