Indeed, zip_entry_read does not return FALSE, but an empty string on EOF.
Confirmed here on PHP 5.4.6 (linux).
zip_entry_read
(PHP 4 >= 4.1.0, PHP 5 >= 5.2.0, PECL zip >= 1.0.0)
zip_entry_read — Leer desde una entrada de directorio abierta
Descripción
string zip_entry_read
( resource
$zip_entry
[, int $length
] )Lee desde una entrada de directorio abierta.
Parámetros
-
zip_entry -
Un directorio devuelto por zip_read().
-
length -
El número de bytes a devolver. Si no se especifica, esta función intentará leer 1024 bytes.
Nota:
Esto debería ser el tramo descomprimido que se desea leer.
Valores devueltos
Devuelve los datos leídos, o FALSE si se llega al final
del documento.
Ver también
- zip_entry_open() - Abrir una entrada de directorio para lectura
- zip_entry_close() - Cierra la entrada a un directorio
- zip_entry_filesize() - Devuelve el tamaño del fichero actual de una entrada de directorio
Tof ¶
4 months ago
Twan ¶
3 years ago
It seems that zip_entry_read returns an empty string (i.e. '') at the end of file instead of FALSE. At least in PHP 5.3 on Windows XP.
Matt ¶
7 years ago
When reading from a zip file if the initial call to zip_entry_read() returns false it would be advisable to run mkdir with the file name since it it very likely that the zero length file was a directory and attempts to save the files within the directory will fail if you dont create it first
