closedir()

closedir() — Close directory handle.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Closes the directory stream indicated by dir_handle.

Signature

closedir(?resource $dir_handle = null): void

Parameters

ParameterTypeWhat it takes
$dir_handle?resourceA directory handle resource previously opened with opendir(). If dir_handle is null the last handle opened using opendir() will be used.

Return value

No value is returned.

Example

The PHP manual ships no example for closedir(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.5.0Using null for dir_handle is now deprecated. Instead, the last opened directory handle should be explicitly provided.
8.0.0dir_handle is now nullable.

See also

opendir(), readdir(), rewinddir(), dir(), is_dir(), glob(), scandir()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page closedir() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.