PHP Function Reference

PHP - Directory



The Directory functions allow you to retrieve information about directories and their contents.

Installation

There is no installation needed to use these functions. These functions are part of the PHP core.

Runtime Configuration

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

PHP Directory Class

Class Description
Directory The Directory class.
MethodsDescription
close() Close directory handle.
read() Read entry from directory handle.
rewind() Rewind directory handle.

PHP Directory Functions

FunctionsDescription
chdir() Changes directory.
dir() Return an instance of the Directory class.
chroot() Change the root directory.
closedir() Close directory handle.
getcwd() Gets the current working directory.
opendir() Open directory handle.
readdir() Read entry from directory handle.
rewinddir() Rewind directory handle.
scandir() List files and directories inside the specified path.

PHP Directory Predefined Constants

The constants below are always available as part of the PHP core.

ConstantsTypeDescription
DIRECTORY_SEPARATORString
PATH_SEPARATORStringSemicolon on Windows, colon otherwise.
SCANDIR_SORT_ASCENDINGInteger
SCANDIR_SORT_DESCENDINGInteger
SCANDIR_SORT_NONEInteger