Why is PHP's zip_read() returning false? I've used this same script before, and it returned true.
$zip = zip_open("/tmp/ayb/test.zip");
if(is_resource($zip))
{
$zip_read=zip_read($zip);
echo($zip_read?'true':'false');
}
Scripts don't magically invert their behaviour for no reason. You changed something. You did something wrong. Don't blame the script. The ZIP got corrupted, or it's a different ZIP, or it's not there any more.
The relevant manual page tells us:
Returns a directory entry resource for later use with the
zip_entry_
... functions, or FALSE if there are no more entries to read, or an error code if an error occurred.
Note that this means you should be testing $zip_read
for more than basic truthiness. You should be examining it more closely for its precise value, and take your debugging from there.
Try to zipped zip archive with normal compession. And check is zip has a password or no. And then dump value:
var_dump($zip_read);
The zip file is empty.
This is the correct answer.