Directory Functions in PHP

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”;
}
=====================================================

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.