我在使用file_get_contents函數時遇到問題。我使用它來獲得來自不同Web服務器的響應,但它不返回任何內容(使用var_dump顯示爲空字符串)。此外,只有在調用此特定服務器時纔會出現問題,因爲我在使用Google的地址時得到了結果;它在我的本地機器上工作正常。 我也試過cUrl - 但結果相同。PHP - 使用file_get_contents問題
1
A
回答
0
你知道:
echo ini_get('allow_url_fopen');
如果這是假的,你應該嘗試調用的file_get_contents讓它在你的php.ini設置爲true。
+1
不能成爲問題,因爲OP說打電話谷歌工作 – Gordon 2010-04-06 10:45:42
+0
哦,你是對的。抱歉。 – Turbotoast 2010-04-06 11:46:54
0
也許你需要設置用戶代理?有些網站可能會檢查並禁止漫遊器。
ini_set('user_agent', 'Name of your bot');
0
這可能與您所調用的服務器的問題是具有適當權限的文件並且可以從普通的Web瀏覽器訪問嗎?如果文件訪問受IP限制,您的服務器的IP是否允許?
相關問題
- 1. PHP file_get_contents問題
- 2. Php file_get_contents()問題
- 3. File_get_contents,PHP,MySQL插入問題
- 4. 使用file_get_contents(PHP)
- 5. json_decode的file_get_contents問題
- 6. 在PHP中使用file_get_contents時訪問$ _SESSION
- 7. 在PHP中使用file_get_contents時訪問$ _SESSION
- 8. 問題php file_get_contents和文件長度
- 9. 使用XML和PHP進行字符編碼問題file_get_contents
- 10. 的mod_rewrite及的file_get_contents問題
- 11. 使用PHP函數file_get_contents
- 12. PHP file_get_contents使用變量
- 13. file_get_contents()連接超時問題
- 14. PHP file_get_contents
- 15. file_get_contents()PHP
- 16. 問題使用PHP
- 17. 問題使用PHP
- 18. PHP無法使用SoapClient或file_get_contents訪問WSDL文件
- 19. 使用file_get_contents讀取PHP代碼
- 20. 如何正確使用php函數file_get_contents?
- 21. 在Google搜索中使用PHP file_get_contents?
- 22. 使用PHP file_get_contents獲取IP地址
- 23. 的file_get_contents和爆炸使用PHP
- 24. 如何使用的file_get_contents在PHP
- 25. 問題來打開的file_get_contents(PHP)的遠程安全文件
- 26. php file_get_contents很慢
- 27. PHP file_get_contents cookie
- 28. 讓PHP的file_get_contents
- 29. php fsockopen curl file_get_contents
- 30. PHP file_get_contents()超時?
請提供'get_headers($ theURL)'的響應,並確保啓用了'error_reporting(-1)'。點擊問題下方的「編輯」鏈接以添加詳細信息。 – Gordon 2010-04-06 07:24:49