a+(read/append) 与 php 中的 a(append) 有何不同
我正在阅读(并慢慢尝试)与 php 中的 txt 文件交互的方法.我已经尝试过追加,它将数据添加到 txt 文件的末尾但是a+和a有什么不同
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
在 w3schools 中它说:
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
a+ 有什么不同,它实际上保留"了什么
What does a+ do differently and what does it actually "Preserve"
推荐答案
使用 a
你可以只追加到文件的末尾.
With a
you can just append to the end of the file.
使用 a+
您也可以读取文件,因此您可以使用 fseek
移动文件指针并在文件中的其他位置添加内容.
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.
相关文章