文章利用了socket來實現異步調用哦,有需要學習socket的朋友可以參考一下本文章以及參考資料哦。 代碼如下 復制代碼
<?
$host = "www.hzhuti.com";
$path = "/Report.php?ReportID=1";
$cookie = Session_id();
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
print "$errstr ($errno)<br />n";
exit;
}
$out = "GET ".$path." HTTP/1.1rn";
$out .= "Host: ".$host."rn";
$out .= "Connection: Closern";
$out .= "Cookie: ".$cookie."rnrn";
fwrite($fp, $out); //將請求寫入socket
//也可以選擇獲取server端的響應
/*while (!feof($fp)) {
echo fgets($fp, 128);
}*/
//如果不等待server端響應直接關閉socket即可
fclose($fp);
?>
更詳細關於php socket可以參考
http://www.bkjia.com/phper/30/7cadb3c9195ac7d8ac9104da61a25c6e.htm