PHP fsockopen函数

来源:互联网 发布:治隆唐宋 知乎 编辑:程序博客网 时间:2024/06/05 20:31

注意:PHP fsockopen需要 PHP.ini 中 allow_url_fopen 选项开启。

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);   if (!$fp) {    //连接错误返回falseecho "$errstr ($errno)<br />\n";   } else {   $out = "GET / HTTP/1.1\r\n";   $out .= "Host: www.example.com\r\n";   $out .= "Connection: Close\r\n\r\n";    fwrite($fp, $out); while (!feof($fp)) {   echo fgets($fp, 128);   } fclose($fp);   }  



0 0
原创粉丝点击