PHP 中file_get_contents 超时问题
来源:互联网 发布:ios11智能拨号软件 编辑:程序博客网 时间:2024/04/26 01:16
今天调试的时候 遇到一个file_get_contents()请求不到值,一直怀疑是服务器那边的问题,最后发现可能是我这边请求数据的时候 还没请求到数据,函数已经超时了 返回了null,php.ini中default_socket_timeout 设置的是60 ,我改成120,没想到竟然获取到了。。。。
下面是网上复制的设置default_socket_timeout 的方法:
通过php.ini中的default_socket_timeout设置,默认超时时间是default_socket_timeout = 60
max_execution_time = 30
default_socket_timeout = 60
假设你使用file_get_contents花费45,而max_execution_time是30,它将超时吗?
答案是NO,因为max_execution_time不影响操作系统调用或stream操作
另一点要指出的的是default_socket_timeout是在socket响应之前计算的,只要得到响应,将会一直执行下去
可以通过以下三种方式设置
1 直接在php.ini中修改 default_socket_timeout =120
2 ini_set('default_socket_timeout', 120);
3 $strm = stream_context_create(array(
'http' => array(
'timeout' => 120
)
)
);
file_get_contents("http://www.example.com/", 0, $strm);
0 0
- PHP 中file_get_contents 超时问题
- PHP中file_get_contents($url)的超时处理
- php file_get_contents超时解决
- file_get_contents fopen超时问题
- PHP file_get_contents设置超时处理
- php中file_get_contents
- php 使用file_get_contents的问题
- PHP内置访问资源的超时时间 time_out file_get_contents read_file
- php file_get_contents请求localhost下url超时问题解决
- 用curl 代替file_get_contents 解决获取网络资源的超时问题
- file_get_contents超时设置
- file_get_contents超时设置时间
- file_get_contents 超时 参数 stream_context_create()
- 关于PHP的file_get_contents的问题
- php file_get_contents
- PHP file_get_contents
- php中 curl, fsockopen ,file_get_contents 三个函数
- php中 curl, fsockopen ,file_get_contents 三个函数
- Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
- Java 数组length总结
- 1111111111
- FIFO
- brk和sbrk
- PHP 中file_get_contents 超时问题
- 更新 hadoop eclipse 插件
- 3M HFE-7100(九氟丁基甲醚)新一代导热液
- StringUtils 开发中常用的字符串格式
- 游戏架构 一种经典的服务器架构
- mybatis学习-入门(1)-单独使用mybatis
- 一个90后IT毕业男的感悟
- 3DMax的OFusion插件使用问题
- Android 4.4, NFS 挂载