當我們使用file_get_contents時,PHP使用什麼來解析域名(本地DNS?)。如何在代理之後使用file_get_contents()?
我問,因爲我得到這個錯誤:
Warning: file_get_contents(http://external-domain.com) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\test.php on line 11
我設法以前解決這個確切的錯誤,當我在一個內部URL使用file_get_contents()
即http://localhost:9090
,問題是我沒有的映射本地主機127.0.0.1在我的Windows機器上的主機文件。添加完後,我可以在內部URL上使用file_get_contents()
。
這可以用類似的方法解決嗎?
這聽起來不像DNS問題。如果您嘗試其他外部域名會發生什麼?這可能是防火牆問題嗎? – 2010-10-14 09:50:01
好吧,我擔心這是一個完全不同的問題,如果它的外部域DNS處理不應該是一個問題,看起來像其他網站只是有問題的迴應,你嘗試使用捲曲? – Hannes 2010-10-14 09:50:21
我訪問的URL是正確的,並且可以被瀏覽器在相同的服務器上訪問。 – Abs 2010-10-14 09:51:10