CakeFest 2024: The Official CakePHP Conference

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

ZipArchive uses class constants. There are various types of constants, main are: Flags (prefixed with FL_), Global flags (prefixed with AFL_), errors (prefixed with ER_) and mode (no prefix).

Archive open modes
ZipArchive::CREATE (int)
Create the archive if it does not exist.
ZipArchive::OVERWRITE (int)
If archive exists, ignore its current contents. In other words, handle it the same way as an empty archive.
ZipArchive::EXCL (int)
Error if archive already exists.
ZipArchive::RDONLY (int)
Open archive in read only mode. Available as of PHP 7.4.3 and PECL zip 1.17.1, respectively, if built against libzip ≥ 1.0.0.
ZipArchive::CHECKCONS (int)
Perform additional consistency checks on the archive, and error if they fail.
Archive global flags
ZipArchive::AFL_RDONLY (int)
Archive is read only, cannot be cleared. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
ZipArchive::AFL_IS_TORRENTZIP (int)
Current archive is torrentzipped. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
ZipArchive::AFL_WANT_TORRENTZIP (int)
Write archive in torrentzip format. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
ZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE (int)
Don't remove file if archive is empty. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
Archive flags
ZipArchive::FL_NOCASE (int)
Ignore case on name lookup
ZipArchive::FL_NODIR (int)
Ignore directory component
ZipArchive::FL_COMPRESSED (int)
Read compressed data
ZipArchive::FL_UNCHANGED (int)
Use original data, ignoring changes.
ZipArchive::FL_RECOMPRESS (int)
Force recompression of data. Available as of PHP 8.0.0 and PECL zip 1.18.0. Deprecated as of PHP 8.3.0 and PECL zip 1.22.1, will be removed in a future version of libzip.
ZipArchive::FL_ENCRYPTED (int)
Read encrypted data (implies FL_COMPRESSED). Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_OVERWRITE (int)
If file with name exists, overwrite (replace) it. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_LOCAL (int)
In local header. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_CENTRAL (int)
In central directory. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_ENC_GUESS (int)
Guess string encoding (is default). Available as of PHP 7.0.8.
ZipArchive::FL_ENC_RAW (int)
Get unmodified string. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_STRICT (int)
Follow specification strictly. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_UTF_8 (int)
String is UTF-8 encoded. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_CP437 (int)
String is CP437 encoded. Available as of PHP 7.0.8.
ZipArchive::FL_OPEN_FILE_NOW (int)
Open the file when added instead of waiting for archive to be closed. Be aware of file descriptors consumption. Available as of PHP 8.3.0 and PECL zip 1.22.1.
Compression modes
ZipArchive::CM_DEFAULT (int)
better of deflate or store.
ZipArchive::CM_STORE (int)
stored (uncompressed).
ZipArchive::CM_SHRINK (int)
shrunk
ZipArchive::CM_REDUCE_1 (int)
reduced with factor 1
ZipArchive::CM_REDUCE_2 (int)
reduced with factor 2
ZipArchive::CM_REDUCE_3 (int)
reduced with factor 3
ZipArchive::CM_REDUCE_4 (int)
reduced with factor 4
ZipArchive::CM_IMPLODE (int)
imploded
ZipArchive::CM_DEFLATE (int)
deflated
ZipArchive::CM_DEFLATE64 (int)
deflate64
ZipArchive::CM_PKWARE_IMPLODE (int)
PKWARE imploding
ZipArchive::CM_BZIP2 (int)
BZIP2 algorithm
ZipArchive::CM_LZMA (int)
LZMA algorithm
ZipArchive::CM_LZMA2 (int)
LZMA2 algorithm. Available as of PHP 7.4.3 and PECL zip 1.16.0, respectively, if built against libzip ≥ 1.6.0.
ZipArchive::CM_ZSTD (int)
Zstandard algorithm. Available as of PHP 8.0.0 and PECL zip 1.19.1, respectively, if built against libzip ≥ 1.8.0.
ZipArchive::CM_XZ (int)
XZ algorithm. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.6.0.
ZipArchive::CM_TERSE (int)
ZipArchive::CM_LZ77 (int)
ZipArchive::CM_WAVPACK (int)
ZipArchive::CM_PPMD (int)
Errors
ZipArchive::ER_OK (int)
No error.
ZipArchive::ER_MULTIDISK (int)
Multi-disk zip archives not supported.
ZipArchive::ER_RENAME (int)
Renaming temporary file failed.
ZipArchive::ER_CLOSE (int)
Closing zip archive failed
ZipArchive::ER_SEEK (int)
Seek error
ZipArchive::ER_READ (int)
Read error
ZipArchive::ER_WRITE (int)
Write error
ZipArchive::ER_CRC (int)
CRC error
ZipArchive::ER_ZIPCLOSED (int)
Containing zip archive was closed
ZipArchive::ER_NOENT (int)
No such file.
ZipArchive::ER_EXISTS (int)
File already exists
ZipArchive::ER_OPEN (int)
Can't open file
ZipArchive::ER_TMPOPEN (int)
Failure to create temporary file.
ZipArchive::ER_ZLIB (int)
Zlib error
ZipArchive::ER_MEMORY (int)
Memory allocation failure
ZipArchive::ER_CHANGED (int)
Entry has been changed
ZipArchive::ER_COMPNOTSUPP (int)
Compression method not supported.
ZipArchive::ER_EOF (int)
Premature EOF
ZipArchive::ER_INVAL (int)
Invalid argument
ZipArchive::ER_NOZIP (int)
Not a zip archive
ZipArchive::ER_INTERNAL (int)
Internal error
ZipArchive::ER_INCONS (int)
Zip archive inconsistent
ZipArchive::ER_REMOVE (int)
Can't remove file
ZipArchive::ER_DELETED (int)
Entry has been deleted
ZipArchive::ER_ENCRNOTSUPP (int)
Encryption method not supported. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_RDONLY (int)
Read-only archive. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_NOPASSWD (int)
No password provided. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_WRONGPASSWD (int)
Wrong password provided. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_OPNOTSUPP (int)
Operation not supported. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.0.0.
ZipArchive::ER_INUSE (int)
Resource still in use. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.0.0.
ZipArchive::ER_TELL (int)
Tell error. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.0.0.
ZipArchive::ER_COMPRESSED_DATA (int)
Compressed data invalid. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.6.0.
ZipArchive::ER_CANCELLED (int)
Operation cancelled. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively, if built against libzip ≥ 1.6.0.
ZipArchive::ER_DATA_LENGTH (int)
Unexpected length of data. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
ZipArchive::ER_NOT_ALLOWED (int)
Not allowed in torrentzip. Available as of PHP 8.3.0 and PECL zip 1.22.0, respectively, if built against libzip ≥ 1.10.0.
Encryption modes
ZipArchive::EM_NONE (int)
No encryption. Available as of PHP 7.2.0 and PECL zip 1.14.0, respectively.
ZipArchive::EM_TRAD_PKWARE (int)
Traditional PKWARE encryption. Available as of PHP 8.0.0 and PECL zip 1.19.0, respectively.
ZipArchive::EM_AES_128 (int)
AES 128 encryption. Available as of PHP 7.2.0 and PECL zip 1.14.0, respectively, if built against libzip ≥ 1.2.0.
ZipArchive::EM_AES_192 (int)
AES 192 encryption. Available as of PHP 7.2.0 and PECL zip 1.14.0, respectively, if built against libzip ≥ 1.2.0.
ZipArchive::EM_AES_256 (int)
AES 256 encryption. Available as of PHP 7.2.0 and PECL zip 1.14.0, respectively, if built against libzip ≥ 1.2.0.
ZipArchive::EM_UNKNOWN (int)
Unknown encryption algorithm. Available as of PHP 8.0.0 and PECL zip 1.19.0, respectively.
Length parameter constants
ZipArchive::LENGTH_TO_END (int)
Use file size, if the file grows additionnal data is ignored, if the file shrinks an error is raised (ZipArchive::ER_DATA_LENGTH). Available as of PHP 8.3.0 and PECL zip 1.22.2.
ZipArchive::LENGTH_UNCHECKED (int)
Use all available data. Available as of PHP 8.3.0 and PECL zip 1.22.2, if built against libzip ≥ 1.10.1.
Other constants
ZipArchive::LIBZIP_VERSION (string)
Zip library version. Available as of PHP 7.4.3 and PECL zip 1.16.0.
Operating system constants for external attributes
ZipArchive::OPSYS_DOS (int)
ZipArchive::OPSYS_AMIGA (int)
ZipArchive::OPSYS_OPENVMS (int)
ZipArchive::OPSYS_UNIX (int)
ZipArchive::OPSYS_VM_CMS (int)
ZipArchive::OPSYS_ATARI_ST (int)
ZipArchive::OPSYS_OS_2 (int)
ZipArchive::OPSYS_MACINTOSH (int)
ZipArchive::OPSYS_Z_SYSTEM (int)
ZipArchive::OPSYS_CPM (int)
ZipArchive::OPSYS_WINDOWS_NTFS (int)
ZipArchive::OPSYS_MVS (int)
ZipArchive::OPSYS_VSE (int)
ZipArchive::OPSYS_ACORN_RISC (int)
ZipArchive::OPSYS_VFAT (int)
ZipArchive::OPSYS_ALTERNATE_MVS (int)
ZipArchive::OPSYS_BEOS (int)
ZipArchive::OPSYS_TANDEM (int)
ZipArchive::OPSYS_OS_400 (int)
ZipArchive::OPSYS_OS_X (int)
ZipArchive::OPSYS_DEFAULT (int)
Since PECL zip 1.12.4
add a note

User Contributed Notes 2 notes

up
60
scott at bluecamel dot eml dot cc
15 years ago
#define ZIP_ER_OK 0 /* N No error */
#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */
#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */
#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */
#define ZIP_ER_SEEK 4 /* S Seek error */
#define ZIP_ER_READ 5 /* S Read error */
#define ZIP_ER_WRITE 6 /* S Write error */
#define ZIP_ER_CRC 7 /* N CRC error */
#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */
#define ZIP_ER_NOENT 9 /* N No such file */
#define ZIP_ER_EXISTS 10 /* N File already exists */
#define ZIP_ER_OPEN 11 /* S Can't open file */
#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */
#define ZIP_ER_ZLIB 13 /* Z Zlib error */
#define ZIP_ER_MEMORY 14 /* N Malloc failure */
#define ZIP_ER_CHANGED 15 /* N Entry has been changed */
#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */
#define ZIP_ER_EOF 17 /* N Premature EOF */
#define ZIP_ER_INVAL 18 /* N Invalid argument */
#define ZIP_ER_NOZIP 19 /* N Not a zip archive */
#define ZIP_ER_INTERNAL 20 /* N Internal error */
#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */
#define ZIP_ER_REMOVE 22 /* S Can't remove file */
#define ZIP_ER_DELETED 23 /* N Entry has been deleted */
up
4
ohcc at 163 dot com
8 years ago
0 ZIPARCHIVE::ER_OK 没有错误。
1 ZIPARCHIVE::ER_MULTIDISK 不支持多磁盘zip压缩包。
2 ZIPARCHIVE::ER_RENAME 重命名临时文件失败。
3 ZIPARCHIVE::ER_CLOSE 关闭zip压缩包失败。
4 ZIPARCHIVE::ER_SEEK 寻址错误
5 ZIPARCHIVE::ER_READ 读取错误
6 ZIPARCHIVE::ER_WRITE 写入错误
7 ZIPARCHIVE::ER_CRC CRC校验失败
8 ZIPARCHIVE::ER_ZIPCLOSED zip压缩包已关闭
9 ZIPARCHIVE::ER_NOENT 没有文件
10 ZIPARCHIVE::ER_EXISTS 文件已经存在
11 ZIPARCHIVE::ER_OPEN 不能打开文件
12 ZIPARCHIVE::ER_TMPOPEN 创建临时文件失败
13 ZIPARCHIVE::ER_ZLIB Zlib错误
14 ZIPARCHIVE::ER_MEMORY 内存分配失败
15 ZIPARCHIVE::ER_CHANGED 条目已被改变
16 ZIPARCHIVE::ER_COMPNOTSUPP 不支持的压缩方式
17 ZIPARCHIVE::ER_EOF 过早的EOF
18 ZIPARCHIVE::ER_INVAL 无效的参数
19 ZIPARCHIVE::ER_NOZIP 不是一个zip压缩包
20 ZIPARCHIVE::ER_INTERNAL Internal
21 ZIPARCHIVE::ER_INCONS Zip压缩包不一致
22 ZIPARCHIVE::ER_REMOVE 不能移除文件
23 ZIPARCHIVE::ER_DELETED 条目已被删除
To Top