readdir
PHP Manual
PHP Manual»Функції для роботи з теками»readdir

readdir

(PHP 4, PHP 5, PHP 7, PHP 8)

readdirRead entry from directory handle

Опис

function readdir(?resource $dir_handle = null): string|false

Returns the name of the next entry in the directory. The entries are returned in the order in which they are stored by the filesystem.

Параметри

dir_handle
A directory handle resource previously opened with opendir(). If dir_handle is null the last handle opened using opendir() will be used.

Значення, що повертаються

Returns the entry name on success, або false в разі помилки.

Увага

Ця функція може повертати як логічне false, так і не логічне значення, яке прирівнюється до false. Докладніше про це описано в розділі Логічні типи даних. Для перевірки значення, яке повертає ця функція, використовується оператор ===.

Журнал змін

Версія Опис
8.5.0 Using null for dir_handle is now deprecated. Instead, the last opened directory handle should be explicitly provided.
8.0.0 dir_handle is now nullable.

Приклади

For a complete example refer to the opendir() documentation.

Прогляньте також

  • opendir() - Open directory handle
  • rewinddir() - Rewind directory handle
  • closedir() - Close directory handle
  • dir() - Return an instance of the Directory class
  • is_dir() - Tells whether the filename is a directory
  • glob() - Find pathnames matching a pattern
  • scandir() - List files and directories inside the specified path
To Top