f +中的w +模式?

Alx*_*ejo 3 php

fopen($handle, 'w+');
Run Code Online (Sandbox Code Playgroud)

我正在寻找打开.CSV文件,读取每一行并对数据库执行某些操作,然后截断.CSV文件并编写类似的内容

此文件已被阅读.

w +意味着读/写,但文件也被截断.那么,如果fopen w +只会删除其中的内容,那么读取的重点是什么?

Mar*_*tin 6

使用 a+

从文档:

'w+'     Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a+'     Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
Run Code Online (Sandbox Code Playgroud)