Home > Article > Backend Development > php file operations
Mode Description
r Open the file as read-only. The file pointer starts at the beginning of the file.
w Open the file for writing only. Delete the contents of the file or create a new file if it does not exist. The file pointer starts at the beginning of the file.
a Open the file for writing only. Existing data in the file will be preserved. The file pointer starts at the end of the file. Create a new file if the file does not exist.
x Create new files as write-only. Returns FALSE and an error if the file already exists.
r+ Open the file for reading/writing, and the file pointer starts at the beginning of the file.
w+ Open the file for reading/writing. Delete the file contents or create a new file if it does not exist. The file pointer starts at the beginning of the file.
a+ Open the file for reading/writing. Data already in the file will be retained. The file pointer starts at the end of the file. Create new file if it does not exist.
x+ Create new files for reading/writing. Returns FALSE and an error if the file already exists.