Home > Backend Development > PHP Tutorial > Reading efficiency of php text files_PHP tutorial

Reading efficiency of php text files_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:21:11
Original
1249 people have browsed it

The homepage is about 3KB and was tested locally

Copy the code The code is as follows:

file_get_contents('shadow.xml ');

Took 0.0003 seconds
Copy code The code is as follows:

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

Took 0.026 seconds
Copy code The code is as follows:

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

It took 0.0003 seconds
The difference is nearly 100 times! ! It’s really unexpected

I guess all the time is lost in the while loop or something.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324988.htmlTechArticleThe homepage is about 3KB. The copied code for local testing is as follows: file_get_contents('shadow.xml'); consumption Copy the code in 0.0003 seconds. The code is as follows: $indexFile = fopen('shadow.xml', 'r'...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template