Introduction
This article explains Directories in PHP; how to show or get all the information about directories and contents. For this I use the important and useful functions such as chdir(), chroot(), dir(), closedir(), getcwd(), opendir(), readdir(), rewinddir() and scandir(). I discuss them step-by-step. The directory functions are parts of the PHP core.
Syntax
|
chroot(directory); |
| Parameter | Description |
| Directory | Required specifies new root directory. |
Example
This function basically changes the root directory of the current process and this function returns true on success otherwise returns false. This function does not work on the Windows platform since Wndows does not have equivalent functionality.
<?php
chroot("/path/to/your/chroot/");
echo getcwd();
?>
Output
/
Syntax
|
chdir(directory); |
| Parameter | Description |
| Directory | Required. Specifies the directory to change to. |
Example
This function changes the current directory.
<?php
//get current dire
echo getcwd();
echo "<br />";
//change to the file dir
chdir("gallery");
echo "<br />";
echo getcwd();
?>
Output




Comments
Join the conversation! Your thoughts help the community grow.