Google or Baidu, a lot of such problems, the solution is to modify php.ini, allow_url_fopen to enable, changed to Allow_url_fopen = On
This can solve some people's problems, it is said that in php.ini, there are two options: Allow_url_fopen =on (which means that remote files can be opened via a URL), user_agent= "PHP" (indicates which script accesses the network by default, preceded by a ";" Remove the can. ) reboot the server.
But some still will have this warning message, want to use perfect solution still one step, still have to set php.ini inside user_agent,php default user_agent is PHP, we change it to mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) to simulate the browser is OK
User_agent= "mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.0) "
Encounter this problem in the work, after the perfect solution, so share to everybody.
I batch crawl chemblink of the structure of the loop found that some of the pictures can not be displayed, and remote files exist.
A similar warning:readfile (http://www.jb51.net/logo.gif) [Function.readfile] appears when crawling remote files: Failed to open stream:http request failed! Such a warning message that I used to be
Copy Code code as follows:
Ob_start ();
ReadFile ("Yun_qi_img/logo.gif");
$img = Ob_get_contents ();
Ob_end_clean ();
So in the running will occur from time to time the above error, I have changed file_get_contents and other functions are useless, in the online lookup found that with the curl method to crawl can not be wrong
Now more popular Use curl
Copy Code code as follows:
<?php
$url = "Http://s.jb51.net";
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_connecttimeout,10);
$dxycontent = curl_exec ($ch);
Echo $dxycontent;
?>