2

This works perfectly

curl http://google.com

This doesn't:

php -r "echo file_get_contents('http://google.com');

I am getting the warning:

PHP Warning: file_get_contents(google.com): failed to open stream: Connection timed out"

but then if I do something like

php -r "echo file_get_contents('http://localhost:8000');

on a local server it works, somehow I must have messed something in the php configuration, can anyone one have a clue to solve this?

k0pernikus
  • 60,309
  • 67
  • 216
  • 347
  • Are you getting any errors? We can't help you with "this doesn't work" – Machavity Dec 20 '15 at 02:02
  • 1
    Here is an answer http://stackoverflow.com/questions/3488425/php-ini-file-get-contents-external-url – rafwlaz Dec 20 '15 at 02:02
  • Yes sorry, I am getting the typical "PHP Warning: file_get_contents(http://google.com): failed to open stream: Connection timed out" – Roger Rodriguez Texido Dec 20 '15 at 02:21
  • 1
    Duplicate of https://stackoverflow.com/questions/4189973/file-get-contents-connection-timed-out – k0pernikus Dec 20 '15 at 02:29
  • Yes @k0pernikus you're right, file_get_contents is not suited for this purpose I usually would use guzzle but I was lazy, I changed it to classical curl_int() ... and worked, my internet connection seems to be messed up. – Roger Rodriguez Texido Dec 20 '15 at 02:36
  • @user3377450 I editted your question. Please use the formatting option to the codebase. Instead of posting code in the comments, edit your question. And finally, keep the question short and to the point. – k0pernikus Dec 20 '15 at 02:58

0 Answers0