php中file_get_content 和curl以及fopen 效率分析
2014-09-19 00:00
1421 查看
三个函数虽然都是读取资源的函数,但各自的应用场景不同。
curl多用于互联网网页之间的抓取,fopen多用于读取文件,而file_get_contents多用于获取静态页面的内容。
1. fopen /file_get_contents 每次请求都会重新做DNS查询,并不对DNS信息进行缓存。但是CURL会自动对DNS信息进行缓存。对同一域名下的网页或者图片的请求只需要一次DNS查询。这大大减少了DNS查询的次数。所以CURL的性能比fopen /file_get_contents 好很多。
2. fopen /file_get_contents在请求HTTP时,使用的是http_fopen_wrapper,不会keeplive。而curl却可以。这样在多次请求多个链接时,curl效率会好一些。
3. curl可以模拟多种请求,例如:POST数据,表单提交等,用户可以按照自己的需求来定制请求。而fopen / file_get_contents只能使用get方式获取数据。
curl多用于互联网网页之间的抓取,fopen多用于读取文件,而file_get_contents多用于获取静态页面的内容。
1. fopen /file_get_contents 每次请求都会重新做DNS查询,并不对DNS信息进行缓存。但是CURL会自动对DNS信息进行缓存。对同一域名下的网页或者图片的请求只需要一次DNS查询。这大大减少了DNS查询的次数。所以CURL的性能比fopen /file_get_contents 好很多。
2. fopen /file_get_contents在请求HTTP时,使用的是http_fopen_wrapper,不会keeplive。而curl却可以。这样在多次请求多个链接时,curl效率会好一些。
3. curl可以模拟多种请求,例如:POST数据,表单提交等,用户可以按照自己的需求来定制请求。而fopen / file_get_contents只能使用get方式获取数据。
相关文章推荐
- php中file_get_content 和curl以及fopen 效率分析
- php中file_get_content 和curl以及fopen
- php读取网络文件curl,fsockopen,file_get_contents,file,fopen几种方法
- fopen、file_get_content、fsocket、curl下载图片
- 探讨file_get_contents与curl效率及稳定性的分析
- php中curl、fsocket、file_get_content三个函数的使用比较
- php fopen,file_get_contents,curl的区别
- php读取网络文件 curl, fsockopen ,file_get_contents 几个方法的效率对比
- 探讨file_get_contents与curl效率及稳定性的分析
- PHP中fopen,file_get_contents,curl的区别
- 使用PHP的curl扩展实现跨域post请求,以及file_get_contents()百度短网址例子
- php读取网络文件(curl, fsockopen ,file_get_contents 几个方法的效率对比)
- php中file_get_contents与curl性能比较分析
- php中file_get_contents与curl性能比较分析
- php读取网络文件 curl, fsockopen ,file_get_contents 几个方法的效率对比
- PHP中file_get_contents于curl性能效率比较
- php读取网络文件 curl, fsockopen ,file_get_contents 几个方法的效率对比
- php中curl、fsocket、file_get_content三个函数的使用比较
- php中file_get_contents与curl性能比较分析
- php中file文件操作函数readfile fread fgets fgetc以及不需要加fopen的file_get_contents file_put_contents file()