PHP - File Close
The next step after you have
opened a file is to close that
file.
Description
In PHP it is not system to
close all your files after using
them because the server will close
all files after the PHP code
finishes execution.
File Close Function
In a previous section, we had a
call to the function fclose to
close down a file after we were
done with it.
PHP Code
$fname = “first.txt”;
$handle = fopen($fname, ‘w’) or
die(”can’t open file”);
fclose($handle);
The function fclose requires
the file handle that we want to
close down. In our example we set
our variable “$fileHandle” equal
to the file handle returned by the
fopen function.
After a file has been closed
down with fclose it is impossible
to read, write or append to that
file unless it is once more opened
up with the fopen function.
|
|
|
|