【发布时间】:2012-11-17 08:18:10
【问题描述】:
我有这个代码:
$feed = 'urltorss';
$feeds = new SimpleXmlElement( file_get_contents($feed) );
$feed = 'http://www.businessweek.com/feeds/homepage.rss';
$feeds = new SimpleXmlElement( file_get_contents($feed) );
现在 both url 没有任何特殊字符需要对其进行 url 编码,但第二个 url 有一个 .rss 扩展如果它是相关的。
第一次调用有效,第二次在我的服务器上尝试时超时,但在 localhost 上完美运行。
这是我得到的错误:
Severity: Warning
Message: file_get_contents('http://www.businessweek.com/feeds/homepage.rss')
[function.file-get-contents]:
failed to open stream: Connection timed out
Filename: controllers/mailsystem.php
Line Number: 36
这是为什么呢?
【问题讨论】:
-
很可能是由于您的 PHP 设置。尝试将脚本超时设置为更高的值。
-
超时是固定超时,在 localhost 中加载速度非常快,如果第一个有效,这怎么可能是设置?
-
究竟是什么超时?您的脚本或请求?
-
可以添加网址吗?您可以更改网址中的域名或文件名。
-
第一个文件在您的服务器中,第二个文件在您的服务器之外,对吧?
标签: php timeout file-get-contents