PHP | Directory Functions

PHP Directory Functions


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP Directory Functions.

The PHP directory functions are used in manipulating any directory.

Installation

There is no Installation needed to use these functions; they are part of the PHP core.

PHP needs to be configured with the --enable-chroot-function option to enable chroot() function.


Runtime Configuration

This extension type has no configuration directives defined in php.in.

List of Directory Functions

The following below is the list of directory functions supported in PHP. PHP - indicates the earliest versions of PHP that have support for the functions.

Sr.NoFunction & DescriptionPHP
1chdir()

Changes current directory

4
2chroot()

Change the root directory

4.0.4
3dir()

Opens a directory handle and returns an object.

4
4closedir()

Closes a directory

4
5getcwd()

Gets the current working directory.

4
6opendir()

Open directory handle

4
7readdir()

Read entry from directory handle

4
8rewinddir()

Rewind directory handle

4
9scandir()

List files and directories inside the specified path


In our subsequent tutorials, we are going to be discussing about the above listed PHP directory functions.

Directory Constants

The following below is the list of directory constants supported in PHP. PHP - indicates the earliest versions of PHP that have support for these constants.

Sr.NoConstant & DescriptionPHP
1

DIRECTORY_SEPARATOR

3
2

PATH_SEPARATOR

4


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about PHP chdir() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.