php执行URL解析

方法一:$url=http://www.baidu.com;file_get_contents(网络
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

方法一:

$url="http://www.baidu.com";
file_get_contents($url);

 

方法二:

// CURL 方法
          $url="http://www.baidu.com";
          $ch = curl_init(  );
          curl_setopt( $ch,CURLOPT_URL,$url );
          curl_setopt( $ch,CURLOPT_HEADER,0 );
          curl_setopt( $ch,CURLOPT_RETURNTRANSFER,1 );
          $ret= curl_exec( $ch );
          curl_close( $ch );
          echo $ret;

方法三:

$url="http://www.baidu.com";
    $fp=fopen($url,"r");
    $response = '';
            while($row = fgets($fp)) {
                $response.= trim($row)."\n";
            }      

 

注意:如果ping的通但是无法调用远程url,试试wget

Resolving www.xxx.com... 114.xxx.xxx.xxx
Connecting to www.xxx.com|114.xxx.xxx.xxx|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
10:58:22 ERROR 403: Forbidden.

 

这样就不可以!

本文来源21aspnet,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/2791

发表评论