【问题标题】:Connection Timeout With File_get_contents()File_get_contents() 连接超时
【发布时间】:2011-01-19 04:45:56
【问题描述】:

我正在编写一个从 Web 服务器获取 csv 文件的脚本。我目前正在使用 file_get_contents。有时我会收到消息

Warning: file_get_contents failed to open stream: Connection timed out

我认为这可能是由于网站关闭。或者是否存在网站正常但仍显示此警告的情况。还有 CURL 比这个功能有什么优势。

【问题讨论】:

    标签: php file curl


    【解决方案1】:

    这是因为远程 url 有 404 错误。

    【讨论】:

      【解决方案2】:

      要访问远程文件,您应该使用 cURL。如果远程服务器耗时过长,您可以将 cURL 设置为静默超时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-01-29
        • 2013-08-29
        • 2015-09-16
        • 2012-04-28
        • 2014-06-22
        • 1970-01-01
        • 2020-10-08
        • 2022-01-21
        相关资源
        最近更新 更多