How can debugging techniques be used to troubleshoot issues with counting ZIP files in PHP?

Issue: The code is not correctly counting ZIP files in a directory using PHP. To troubleshoot this issue, we can use debugging techniques such as printing out the file names to ensure they are being correctly read and checking the condition used to filter ZIP files.

$directory = 'path/to/directory';
$zipFiles = 0;

$files = scandir($directory);

foreach ($files as $file) {
    if (is_file($directory . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) == 'zip') {
        $zipFiles++;
    }
}

echo "Total ZIP files: " . $zipFiles;