What are common pitfalls when trying to unzip a file using PHP?

Common pitfalls when trying to unzip a file using PHP include not having the necessary PHP Zip extension installed, incorrect file paths specified, and insufficient permissions to write to the destination directory. To solve these issues, ensure that the PHP Zip extension is installed, double-check the file paths, and make sure the destination directory has proper write permissions.

$zipFile = 'example.zip';
$destination = 'unzipped/';

$zip = new ZipArchive;
if ($zip->open($zipFile) === TRUE) {
    $zip->extractTo($destination);
    $zip->close();
    echo 'File unzipped successfully.';
} else {
    echo 'Failed to unzip the file.';
}