//1.html
1
2
3
4
5
//1.php
<?php
echo "<pre>";
//fsockopen(地址,端口坛善,錯誤碼兔毙,錯誤信息,超時) 返回類型
$fh = fsockopen ('127.0.0.1' , 80 ,$errno , $errstr , 5);
//
$req = array(
'GET /1.html HTTP/1.1',
'Host: localhost',
'',
''
);
//拆分資源
$req = implode("\n", $req);
//寫入資源
fwrite($fh, $req);
//循環(huán)讀取資源啊
while($row = fread($fh,32)) {
echo $row;
}
fclose($fh)
?>
頁面輸出結(jié)果如下
HTTP/1.1 200 OK
Date: Sat, 06 Aug 2016 11:50:49 GMT
Server: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/5.5.30
Last-Modified: Sat, 06 Aug 2016 11:33:17 GMT
ETag: "f-539658ca10d41"
Accept-Ranges: bytes
Content-Length: 15
Content-Type: text/html
1
2
3
4
5