What are some best practices for handling hidden files and directories in PHP when using functions like glob()?

When using functions like glob() in PHP to retrieve files and directories, hidden files and directories (those starting with a dot) may not be included in the results by default. To include hidden files and directories, you can use the GLOB_BRACE flag in combination with GLOB_MARK to include hidden files and directories in the results.

$files = glob('.{*,.*}', GLOB_BRACE | GLOB_MARK);
foreach ($files as $file) {
    echo $file . PHP_EOL;
}