I asked this question here , but hardly, for being a problem that seems to be specific, the solution would be something that would be something generic.
But it occurred to me in this question that I asked is that I'm having problems with the file_get_contents
function.
When I make a request through it, an error is always returned:
file_get_contents('https://getcomposer.org/versions')
The return is:
PHP warning: file_get_contents(https://getcomposer.org/versions): failed to open stream: Connection timed out on line 1
However, when I open this url in the browser, everything works perfectly. Furthermore, if I try to make the request in url https://www.google.com
the same problem occurs.
But the strange thing is that not all urls are causing this problem.
If I do this, it works:
file_get_contents('https://pt.stackoverflow.com/')
I thought at first that the problem was with https
in urls, but that does not seem to be it.
If I use curl
it works, but I do not want to use it, because I depend exclusively on file_get_contents
on that occasion.
What can you do with what file_get_contents
gives timeout error in some specific urls, which do they normally open by the browser?
Remark : I would not like answers like "using curl as a workaround," since I really need to use file_get_contents for this purpose of the more, an answer with
curl
would not answer my question).