How is a+(read/append) different from a(append) in

2020-02-15 07:41发布

问题:

I am reading(and slowly trying) the ways to interact with a txt file in php. I have already tried append and it adds data to the end of the txt file But how is a+ different from a

In w3schools it says:

a Append. Opens and writes to the end of the file or creates a new file if it doesn't exist

a+ Read/Append. Preserves file content by writing to the end of the file

What does a+ do differently and what does it actually "Preserve"

回答1:

With a you can just append to the end of the file.

With a+ you can read the file too, so you can move the file pointer using fseek and add content somewhere else inside the file.