【发布时间】:2011-04-17 09:22:27
【问题描述】:
我正在尝试获取外部 PHP 文件的(预处理)内容:
file_get_contents('http://www.example.org/myfile.php');
当我这样做时,我得到一个错误:
警告:file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: nodename or servname provided, or not known in /Applications/XAMPP/xamppfiles/htdocs/...localfile.php on line 13
还有:
警告:file_get_contents(http://www.example.org/myfile.php) [function.file-get-contents]:未能打开流:php_network_getaddresses:getaddrinfo 失败:提供节点名或服务名,或在/Applications/XAMPP/xamppfiles/htdocs/.../localfile.php 第 13 行
有什么想法可以做吗?
提前致谢!
编辑:我确实将 allow_url_fopen 设置为“开启”。
【问题讨论】:
-
你的 php.ini 中有 allow_url_fopen = On 吗?
-
这很可能是 DNS 问题。
-
您可能处于禁用 allow_url_fopen 的安全模式,请改用 cURL。
标签: php http file-get-contents