<?php
$a = file_get_contents('http://www.google.com');
echo $
Why is the browser returning this error?
Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: Connection timed out in /home/test.php on line 2
Mostly probably your server cannot connect to an external resource, for example, because of firewall restrictions.
file_get_contents
does not work well at all with getting remote files and should not be used. It does not deal with slow network connections or redirects, and does not return error codes. You should use curl
instead to fetch remote files.
There is an example in the manual for curl_exec
: http://us3.php.net/manual/en/function.curl-exec.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With