Directory Functions in PHP
Open a Directories & Sub-Directories from PHP Script.
In PHP, there are functions available to handle a directories
and sub-directories from the PHP script.
Some of the Directory Functions used in PHP are:
- chroot - change the root directory
- chdir - change directory
- dir - directory class
- closedir - close directory handle
- getcwd - gets the current working directory
- opendir - open directory handle
- readdir - read entry from directory handle
- rewinddir - rewind directory handle
Example Script to open a directory:
if ($dir = opendir($root))
{
while (($innerfile = readdir($dir)) !== false)
{
if(is_dir ($innerfile))
echo “directory”;
else
} echo “file”;
}
=====================================================
