Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dir

A directory, or dir, is a named collection of files on the file system.

A dir may also be called a folder.

There is a magic constant called __DIR__, which holds the current directory of the current file.

<?php

    $d = dir('/path/to/folder');
    while (false !== ($fileOrDir = $d->read())) {
       echo $fileOrDir.PHP_EOL;
    }
    $d->close();
    
    print_r(scanddir('/path/to/folder'));

?>

Documentation

See Also