What best practices should be followed when determining if a folder contains files in PHP?

When determining if a folder contains files in PHP, it is best practice to use the `scandir()` function to get a list of files in the directory and then check if the array returned is not empty. This ensures that you are accurately checking if there are files present in the folder.

$folder = 'path/to/folder';

$files = scandir($folder);

if (count($files) > 2) {
    echo 'Folder contains files.';
} else {
    echo 'Folder is empty.';
}