Home  >  Article  >  Backend Development  >  header跳转跟file_get_contents,哪种速度快些

header跳转跟file_get_contents,哪种速度快些

WBOY
WBOYOriginal
2016-06-13 11:15:07749browse

header跳转和file_get_contents,哪种速度快些?
不管是显示还是下载,就是比较它们的速度。我不会,请叫大家。

第一种写法:
header(url地址);
exit();

第二种写法:
echo @file_get_contents(url地址);
exit();

header file_get_contents
------解决方案--------------------
在服务器上用file_get_contents获取目标页后发送给用户
相当于客户端使用代理访问目标页

至于谁快谁慢,需要实地测试

------解决方案--------------------
引用:
引用:引用:在服务器上用file_get_contents获取目标页后发送给用户
相当于客户端使用代理访问目标页

至于谁快谁慢,需要实地测试
具体应该怎么测啊?不会啊......
每种方式都循环100次看看所用时间哪个大,当然了两种测试要间隔一段时间在测试,不然会出现误差
    ……

最好是重启机器或者清理内存,不然上次的测试所占用的内存影响下次测试的结果
------解决方案--------------------
外在因素太多,首先性质就是不一样一个站内一个站外,header访问考验两次客户端到服务器端的响应时间,file_get_contents 考验客户端到服务器 服务器到源文件服务器两个响应时间,这种东西没法具体判断,只能做分析
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn