php file_get_contents下载优化

作者:

业务中需要下载文件,原先用的file_get_contents方式,导致下载接口超时报错。

问题

下载接口超时报错

原因

echo file_get_contents($down_url);

通过echo file_get_contents()方式,速度过慢

解决

利用 readfile() 函数替代 file_get_contents()

readfile($url) 等价于 echo file_get_contents($url)

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注