<p >用PHP判断服务器是否支持GZIP</p>
<p ><img alt="" src="/up_pic/201211/20121107081939.jpg" /></p>
<p ><?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 " $errstr ( $errno )<br />n" ;<span class="Apple-converted-space"></span><br />
} else {<span class="Apple-converted-space"></span><br />
fwrite ( $fp , "HEAD /?gzip HTTP/1.1<br />
Host: xxxx.com<br />
Accept-Encoding:gzip, deflate</p>
<p >" );<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 />
?></p>
<p ></p>
<p >输出信息看见<span ><span ><span >GZIP</span></span></span>字样就表示已经支持了。</p>