Easy Tutorial
❮ Php Pdo Constants Func Filesystem Fgetss ❯

PHP opendir() Function

PHP Directory Reference Manual

Example

Open a directory, read its contents, and then close it:

Result:


Definition and Usage

The opendir() function opens a directory handle.


Syntax

Parameter Description
path Required. Specifies the path of the directory to be opened.
context Optional. Specifies the context of the directory handle. Context is a set of options that can modify the directory stream's behavior.

Technical Details

Return Value: Returns a directory handle resource on success. Returns FALSE on failure. If the path is not a valid directory, or if the directory cannot be opened due to permission restrictions or filesystem errors, an E_WARNING level error is thrown. You can suppress the error output of opendir() by prefixing the function name with '@'.
PHP Version: 4.0+
--- ---
PHP Update Log: PHP 5.0: The path parameter supports the ftp:// URL wrapper.
--- ---
❮ Php Pdo Constants Func Filesystem Fgetss ❯