Method 1:
Copy the code The code is as follows:
$url="http://www.baidu. com";
file_get_contents($url);
Method 2:
Copy code The code is as follows:
// CURL method
$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;
Method three:
Copy the code The code is as follows:
$url="http://www.baidu. com";
$fp=fopen($url,"r");
$response = '';
while($row = fgets($fp)) {
$response.= trim($row)."n";
}
Note: If ping works but the remote url cannot be called, try wget
Copy code The code is as follows:
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.
That’s not possible!
http://www.bkjia.com/PHPjc/718622.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/718622.htmlTechArticleMethod 1: Copy the code as follows: $url="http://www.baidu.com"; file_get_contents ($url); Method 2: Copy the code as follows: // CURL method $url="http://www.baidu.com"; $c...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn