$file='www.xxx.com.cn';
$fp = fsockopen($file, 80, $errno, $errstr);
if (!$fp) {
echo "999";
echo "$errstr ($errno) <br />\n";
} else {
fputs($fp,"GET / HTTP/1.0\nHost: $file\n\n");
while(!feof($fp)) {
echo file_get_contents($fp);
}
fclose($fp);
}报错:
HTTP/1.1 400 Bad Request Content-Type: text/html Date: Fri, 08 Apr 2011 06:46:11 GMT Connection: close Content-Length: 39
Bad Request (Invalid Hostname)
不知道是什么原因引起的?希望高手帮帮忙!
說明你给的地址不正确吧
$file='http://www.xxx.com.cn/';
就该 是$file="www.xxx.com.cn";
另外很怀疑你浏览器看到的是不是缓存……