If you want to append to a file, that is, add on to the existing data, then you need to open the file in append mode.
If we want to add on to a file we need to open it up in append "a" mode.
The code below does just that.
If we were to write to the file it would begin writing data at the end of the file.
Study the example shown below:-
Appending data onto a file is actually used everyday.
For example nearly all web servers have a log of some sort.
These various logs keep track of all kinds of information, such as: errors, visitors, and even files that are installed on the machine.
A log is basically used to document events that occur over a period of time, rather than all at once. Logs file is a perfect use for append.
Note
For more detail please see Php Manual at http://www.php.net