How can one delete a folder and its contents created by a PHP script?

To delete a folder and its contents created by a PHP script, you can use the `rmdir()` function in combination with `unlink()` to remove all files within the folder before deleting the folder itself.

$folderPath = 'path/to/folder';

// Remove all files within the folder
$files = glob($folderPath . '/*');
foreach ($files as $file) {
    if (is_file($file)) {
        unlink($file);
    }
}

// Delete the folder itself
if (is_dir($folderPath)) {
    rmdir($folderPath);
}