Home > php教程 > php手册 > php 文本文件的读取效率

php 文本文件的读取效率

WBOY
Release: 2016-06-13 12:02:34
Original
1186 people have browsed it

首页大概3KB,是在本地测试的

复制代码 代码如下:


file_get_contents('shadow.xml');


耗时 0.0003 秒

复制代码 代码如下:


$indexFile = fopen('shadow.xml', 'r');while ( !feof($indexFile)) fgetc( $indexFile);


耗时 0.026 秒

复制代码 代码如下:


$indexFile = fopen('shadow.xml', 'r');fread($indexFile, 10000);


耗时 0.0003秒
相差将近 100 倍!! 还真是出乎意料

我估摸着时间怕都牺牲在while循环上还是怎的
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template