How can PHP be used to check if a folder exists?

To check if a folder exists in PHP, you can use the `file_exists()` function with the path to the folder as the argument. This function will return true if the folder exists and false if it does not.

$folderPath = 'path/to/folder';

if (file_exists($folderPath) && is_dir($folderPath)) {
    echo 'Folder exists.';
} else {
    echo 'Folder does not exist.';
}