How can PHP be used to create a folder on a server and delete a folder with its contents?

To create a folder on a server using PHP, you can use the `mkdir()` function. To delete a folder with its contents, you can use the `rmdir()` function. It's important to ensure that the appropriate permissions are set on the server for these operations to work correctly.

// Create a folder on the server
$folderName = 'new_folder';
if (!file_exists($folderName)) {
    mkdir($folderName);
    echo 'Folder created successfully.';
} else {
    echo 'Folder already exists.';
}

// Delete a folder with its contents
$folderToDelete = 'folder_to_delete';
if (file_exists($folderToDelete)) {
    $files = glob($folderToDelete . '/*');
    foreach ($files as $file) {
        unlink($file);
    }
    rmdir($folderToDelete);
    echo 'Folder deleted successfully.';
} else {
    echo 'Folder does not exist.';
}