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

Posted by Ethan on Stack Overflow See other posts from Stack Overflow or by Ethan
Published on 2010-04-26T00:46:34Z Indexed on 2010/04/26 0:53 UTC
Read the original article Hit count: 270

Filed under:

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.

© Stack Overflow or respective owner

Related posts about php