Efficiency fopen () with 'a' option in PHP

If I write fopen($myfile, 'a'), but $myfile- a very large file, will the server have to read the entire file in order to return the pointer to the end of the file? Or does he quickly find a pointer to the end of the file and then return it?

In the corresponding note, when I use fwrite(), I assume that it does not overwrite the entire file, right? Is he just adding stuff?

Basically I am trying to figure out if there is fopen()an option 'a', and fwrite()this is O (1) or O (n), where n is the length of the precoding file.

+3
source share
3 answers

, PHP , . , fwrite ( , , ).

+4

()
, file_put_contents fopen/fwrite/fclose - :

file_put_contents($filename, $data, FILE_APPEND);

.

+2

No, you fopendo not need to read the entire file to go to it. A simple search is all you need.

+1
source

All Articles