The PHP fopen() function is used to open a file.
"fopen": is the PHP open file function
"$file_name": is the name of the file to be opened
"$mode": is the mode in which the file should be opened.
Read only mode, file pointer will set at the starting position of file.
Read and write mode, file pointer will set at the starting of file.
Write mode only, if the file exists it will open otherwise a new file will be created. If the file already exists, earlier contents will be overwritten
Write and read mode, if file exists contents will be overwritten otherwise a new file will be created.
Append file, if file exists it will open and file pointer will set at the ending of file, if it doesn’t exists a new file will be created.
Read and append mode, if file exists the pointer will set at the end of file, otherwise a new file will be created.
It is used to create and open a file only for writing purpose, if file exists this mode will return false and display an error. If file doesn’t exists it will simply create a file