file_append_contents()ΒΆ
file_put_contents() can append data to the end of the file, with the FILE_APPEND option.
file_put_contents() keeps the file opened as little as possible, and the operation is atomic. It is better then overwriting the whole file; and it is often better than fopen(), which keeps the file open untill the end of the execution.