glob() With Hidden Files

<?php

$path = __DIR__;

// list all files, with and without leading .
$files = glob($path . '/{,.}[!.,!..]*', GLOB_BRACE);

// list all files, except . and ..
$files = glob($path . '/{,.}*', GLOB_BRACE);

By default, the glob() function lists only files that don’t start with a dot .. This means that the hidden files, on Linux, are not listed.

With the GLOB_BRACE option, it is possible to list all files, and even filter out the ever present ‘.’ and ‘..’.

See Also

PHP Features

Last updated: 14 July 2026