【问题标题】:php file_get_contents downloading too much dataphp file_get_contents 下载太多数据
【发布时间】:2017-01-09 10:53:48
【问题描述】:

我注意到,当我使用 file_get_contents 时,我使用的带宽似乎超出了应有的范围。例如:

file_get_contents('https://example.com',false,$ctx,0,99000);

会导致我的网络 RX 跳跃大约 1.6mb(仅使用 ifconfig 并比较前后)....我认为它应该只跳跃 99kb,因为我已经指定了 99000?

【问题讨论】:

  • 你怎么知道 RX 与 PHP 脚本隔离,没有别的?您是否在脚本中运行ifconfig 之前和之后?

标签: php file-get-contents bandwidth


【解决方案1】:

file_get_contents 是 PHP 中一个相当有问题的函数。考虑使用 curl 并遵循以下解决方案:

how to set a maximum size limit to php curl downloads

【讨论】:

  • 非常感谢!! Zizo 博士的回答对我有用......现在降至 200kb 而不是 1.6mb
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-27
  • 2011-07-19
  • 2018-06-09
  • 1970-01-01
  • 1970-01-01
  • 2017-02-14
  • 1970-01-01
相关资源
最近更新 更多