【发布时间】:2016-01-19 20:31:00
【问题描述】:
所以我知道 file_get_contents 一旦收到响应就会调用 fclose() 。但是,如果从未收到响应怎么办? php的默认超时会处理超时响应并关闭连接还是连接保持打开状态?如果连接保持打开状态,我如何确保连接关闭?还是我最好使用 cURL?
【问题讨论】:
-
curl 总是比 file_get_contents 好,因为它比它更安全。
-
同意,我三思而后行。我真正想知道的是 file_get_contents 是如何处理这个问题的。
-
发现了一个和你类似的问题,stackoverflow.com/questions/19650817/…
-
这是用
stream_context_createphp.net/manual/en/function.stream-context-create.php 和php.net/manual/en/context.http.php 用timeout处理的
标签: php file-get-contents