fopen() requires the file path and the mode in which the file is to be opened.
The most common modes are read ('r'), write ('w'), and append ('a').
fopen() returns a file resource you will later use to work with the open file.
To open a file for reading, you would use the following:
$fp = fopen( "test.txt", 'r' );
You would use the following to open a file for writing:
$fp = fopen( "test.txt", 'w' );
To open a file for appending, you would use this:
$fp = fopen( "test.txt", 'a' );
Related examples in the same category