File_get_contents the URL of the extranet is completely fine, but if you want to get a native URL (such as http://localhost/index.php), the following error will be reported:
A connection attempt failed because the connected party does not properly respond after a period of time, or established CO Nnection failed because connected host have failed to respond) while reading response headers from upstream, client:124.2xx . xxx.xxx, server:www.xxx.com, Request: "Get/index.php http/1.0", Upstream: "fastcgi://127.0.0.1:9000", Host: " Www.xxx.com "
Found an article on the internet, http://www.codesky.net/article/201106/174247.html but do not know how to operate under Windows, or there are other ways to help
Reply to discussion (solution)
Trying to add time to that function is also ineffective, such as:
Array ( ' timeout ' = 1//Set a time-out, in seconds ) ) ; File_get_contents ("http://example.com/", 0, $ctx); ? >
Also try to change to curl, still invalid, such as:
$ch = Curl_init (); $timeout = 5;curl_setopt ($ch, Curlopt_url, ' http://localhost/index.php '); curl_setopt ($ch, Curlopt_ Returntransfer, 1); curl_setopt ($ch, Curlopt_connecttimeout, $timeout); $con = Curl_exec ($ch); Curl_close ($ch);
Note: The URL is outside the network completely no problem, as long as the system server and URL is the same server is the same, will not come out, crash
Modify hosts to get a domain name resolved to local
Using domain name access can be solved.
or a direct IP address try it out.
Modify hosts to get a domain name resolved to local
Using domain name access can be solved.
or a direct IP address try it out.
Yes, that's what I did.
Check the php.ini, is not allow_url_fopen = 1?
Also try to replace file_get_contents with include to get the page for localhost.
Check the php.ini, is not allow_url_fopen = 1?
Also try to replace file_get_contents with include to get the page for localhost.
Allow_url_fopen sure it's open.
Tried to use include, incredibly very card, and then at the time of the timeout to achieve the results I want, but after all, is not what I want: supposedly I want to get the content should be within a second can be done.
Although it has been found that other solutions, but still expressed doubts, wondering why, is nginx+php5.3 in Windows bug?
Bug That's not the story. Check your code.
First http://localhost/index.php with simple code, such as echo "Hello World"; Is this the case with simple code?
Second, use Chrome or firebug to look at the request header and the browser's cookies. or without a browser test, test it with a command prompt that comes with Windows. Run, cmd Enter, PHP c:\www\index.php enter. See if the DOS interface returns results?
Have the same problem.
Compared to other people, the feeling is
The question of this,
Mark waits for the master
Have the same problem.
Compared to other people, the feeling is
The question of this,
Mark waits for the master
Brother Tai also want to get the content of a local URL? I actually use this function to generate static, do not know what the elder brother to do, hehe, a little curious.
But I solved it in other ways, that is, using AJAX to request the local URL, the effect is the same.
Encounter the same problem. Ask landlord now have solution
The same question, ask
function __curl_get ($url) {
/*print_r (Phpinfo ()); exit;*/
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_header, false);
curl_setopt ($ch, Curlopt_returntransfer, 1);
$ret = curl_exec ($ch);
Curl_close ($ch);
return $ret;
}
Crawling the web with this function is good. To add the curl_init () extension in order to use the