php教程

file_get_contents函数访问大文件超时解决方法

php教程 51源码 2023-05-08 人阅读

file_get_contents函数在访问大文件时,会报错504超时,下面分享下我的站长站的解决方法。

$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>60,
)
);
 
$context = stream_context_create($opts);
 
$html =file_get_contents('https://www.51yma.cn', false, $context);

这样,file_get_contents获取数据时,超出60秒将会自动退出。


版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/php/1226.html
文章来源:
标签 PHP函数