How can PHP be used to determine if a folder contains files or subfolders?

To determine if a folder contains files or subfolders in PHP, you can use the `scandir()` function to get a list of all files and subfolders within the specified directory. You can then loop through the list and check if each item is a file or a directory using `is_file()` and `is_dir()` functions.

$directory = 'path/to/folder';

$contents = scandir($directory);

foreach ($contents as $item) {
    if ($item != '.' && $item != '..') {
        if (is_file($directory . '/' . $item)) {
            echo $item . ' is a file<br>';
        } elseif (is_dir($directory . '/' . $item)) {
            echo $item . ' is a directory<br>';
        }
    }
}