Fread () is used to read the contents of the file for as many bytes as you specify, and return the data to the PHP file.
Another way to read a file is line by line. This is how it is read if you use the fgets () function. It then leaves the pointer at the end of the last line read.
If you want to add data to the file you can do so using the fwrite () command. This will write directly from the current position of the pointer.
If you are writing to a file and do not wish to overwrite what is already there, you need to find the end of the file using the feof () function. This will place the pointer at the end of the last data in the file.