October 2002
Intermediate to advanced
368 pages
7h 12m
English
Before you can use PHP to read a file, you must first open it. To open a file, you use the fopen() function.
$file_handler = fopen($file, $mode)
You must assign the function to a variable, as above. This is referred to as a file pointer. You use the file pointer to reference the open file throughout your script.
The fopen() function takes two arguments:
$file is the name (and path, if required) of the file.
$mode is one of a list of available modes:
r— Open the file as read-only. You cannot write anything to the file. Reading begins at the beginning of the file.
r+ — Open the file for reading and writing. Reading and writing begin at the beginning of the file. You will delete existing contents if you write ...
Read now
Unlock full access