例子,检测主机空间是否开启pfsockopen函数?
复制代码 代码示例:
<?php
$fp = pfsockopen("www.yuju100.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />n"; }
else {
$out = "GET / HTTP/1.1rn";
$out .= "Host: www.yuju100.comrn";
$out .= "Connection: Closernrn";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
fsockopen函数被禁用的解决方法:
如果服务器没有同时禁用pfsockopen,直接将fsockopen函数替换为pfsockopen。