Php text file reading efficiency. The homepage is about 3 kB. the code for copying the code tested locally is as follows: file_get_contents (shadow. xml); it takes 0.0003 seconds to copy the code as follows: $ indexFilefopen (shadow. xml, r homepage about 3 kB, tested locally
The code is as follows:
File_get_contents ('shadow. XML ');
Time: 0.0003 seconds
The code is as follows:
$ IndexFile = fopen ('shadow. XML', 'r'); while (! Feof ($ indexFile) fgetc ($ indexFile );
Time: 0.026 seconds
The code is as follows:
$ IndexFile = fopen ('shadow. XML', 'r'); fread ($ indexFile, 10000 );
Time: 0.0003 seconds
The difference is nearly 100 times !! Unexpectedly
I guess the time is always sacrificed in the while loop.
The example code is as follows: file_get_contents ('shadow. XML'); the code that takes 0.0003 seconds is as follows: $ indexFile = fopen ('shadow. XML', 'R '...