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

php 文本文件的读取效率

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:02:34
Original
1236 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循环上还是怎的
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template