Using file_get_contents to crawl the content of the page is not successful, probably because some host service providers put PHP allow_url_fopen option is off, it is impossible to directly use file_get_contents to get the content of the remote Web page. That is, you can use another function curl.
Here are the different ways to file_get_contents and curl two functions
Example of using the File_get_contents function:
Copy Code code as follows:
< PHP
$file _contents = file_get_contents (' http://www.jb51.net ');
echo $file _contents;
?>
To use an example of a curl function:
Copy Code code as follows:
< PHP
$ch = Curl_init ();
$timeout = 5;
curl_setopt ($ch, Curlopt_url, ' http://www.jb51.net ');
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
$file _contents = curl_exec ($ch);
Curl_close ($ch);
echo $file _contents;
?>