What are potential performance issues when reading all files from a directory in PHP?

Reading all files from a directory in PHP can lead to potential performance issues if the directory contains a large number of files. This can slow down the script and consume a lot of memory. To improve performance, you can use the `scandir()` function to retrieve the list of files in the directory and then process them one by one.

$dir = '/path/to/directory';
$files = scandir($dir);

foreach($files as $file) {
    if($file != '.' && $file != '..') {
        // Process each file here
    }
}