Checking Existence and Protection Status of Files and Directories

chinmay.sahoo

New member
PHP has a number of functions for checking whether a fi le or directory exists and if so its status. The main ones are:


• fi le_exists. This takes a relative fi le or directory name as its argument and returns true if either a fi le or a directory with that name and path exists. Otherwise it returns false.
• is_fi le. This takes a relative fi le name as its argument and returns true if a file with that name and path exists. Otherwise it returns false.
• is_dir. This takes a relative directory name as its argument and returns true if a directory with that name and path exists. Otherwise it returns false.
• is_readable. This takes a relative fi le or directory name as its argument and returns true if a fi le or directory with that name and path exists and is readable.
Otherwise it returns false.
• is_writable. This takes a relative fi le or directory name as its argument and returns true if a fi le or directory with that name and path exists and is writable. Otherwise it returns false.
• is_writeable. This is an alias for function is_writable.
 
Back
Top