Working With File and Directories
Working With File and Directories
Modes Description
r Open a file for read only. File pointer starts at the beginning of the file
r+ Open a file for read/write. File pointer starts at the beginning of the file
Open a file for write only. Erases the contents of the file or creates a new file if it doesn't exist. File
w
pointer starts at the beginning of the file
Open a file for read/write. Erases the contents of the file or creates a new file if it doesn't exist. File
w+
pointer starts at the beginning of the file
Modes Description
Open a file for write only. The existing data in file is preserved. File pointer starts at the end of the file.
a
Creates a new file if the file doesn't exist
Open a file for read/write. The existing data in file is preserved. File pointer starts at the end of the file.
a+
Creates a new file if the file doesn't exist
x Creates a new file for write only. Returns FALSE and an error if file already exists
x+ Creates a new file for read/write. Returns FALSE and an error if file already exists
fread($myfile,filesize("webdict
ionary.txt"));
6
A second, optional argument allows the
specification of permissions on the directory
(controlling such issues as whether the directory
is writable):
<?php
$result = mkdir ("/path/to/directory",
"0777");
?>
<?php
$current_dir = getCwd();