Ways to open a file in PHP are given below:
1. r: Open a file for read only. File pointer points at the beginning of the file.
2. w: Open a file for write only. File pointer begins at the beginning of the file. It erases all the data of the file or create a new file if file does't exist and start writing from the beginning of the file.
3. a: Open a file for write only. File pointer starts at the end of the file. If the file doesn't exist it will create a new file.
4. x: Creates a new file for write only purpose and return false if the file already exist.
5. r+: It opens a file for read/write purpose. File pointer points at the beginning of the file.
6. w+: It opens a file for read/write purpose. File pointer begins at the beginning of the file. It erases all the data of the file or create a new file if file does't exist and start writting from the beginning of the file.
7. a+: Open a file for read/write only. File pointer starts at the end of the file. If the file doesn't exist it will create a new file.
8. x+: It will create a new file for read/write purpose and return false if the file already exist.
0 Comment(s)