PHP provides several functions to tell you about various file
attributes. PHP has the ability to read data from, and write data to, files on
your system. However, it doesn't just stop there. It comes with a full-featured
file-and-directory-manipulation API that allows you to:
All of this file manipulation through the API is robust and
flexible. These characteristics are why we're writing this book. PHP has a lot
of great commands, including all the file manipulation ones.
Now that you know a file exists, you may think you're done, but
you're not. Just because it's there doesn't mean you can read, write, or execute
the file. To check for these attributes, use
is_readable to check for read access,
is_writable to check for write access, and
is_executable to check for the ability to
execute the file. Each function takes a filename as its parameter. Unless you
know the file is in the same directory as your script, you
must specify a full path to the file in the filename.
You can use concatenation to put the path and filename together, as in:
$file_name = $path_to_file . $file_name_only;