开发者

PHP file_get_contents() does not work after uploading to the webserver

Sample code:

$html = file_get_contents('http://www.google.com');
echo $html;

It works on localhost. But after uploading to the webserver, it gives me a warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution. If I replace the domain name 开发者_运维百科with google's IP address, it gives a warning: failed to open stream: Connection timed out.

And ini_get("allow_url_fopen") return 1.

===

Edit: Probably it is a server problem. I guess this question should be asked on serverfault.com.


Your host is most likely refusing the outbound connection. It's the only thing I can think of.


This is a known bug in some versions of PHP. Tell your host about the problem and ask them to upgrade PHP.

It's also possible that your host have extremely naive firewall rules in place blocking just about any networking you try to do. Which host is it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜