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
Create the archive if it does not exist.
ZipArchive::OVERWRITE
If archive exists, ignore its current contents. In other words, handle it the same way as an empty archive.
ZipArchive::EXCL
Error if archive already exists.
ZipArchive::RDONLY
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
Perform additional consistency checks on the archive, and error if they fail.
Archive global flags
ZipArchive::AFL_RDONLY
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
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
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
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
Ignore case on name lookup
ZipArchive::FL_NODIR
Ignore directory component
ZipArchive::FL_COMPRESSED
Read compressed data
ZipArchive::FL_UNCHANGED
Use original data, ignoring changes.
ZipArchive::FL_RECOMPRESS
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
Read encrypted data (implies FL_COMPRESSED). Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_OVERWRITE
If file with name exists, overwrite (replace) it. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_LOCAL
In local header. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_CENTRAL
In central directory. Available as of PHP 8.0.0 and PECL zip 1.18.0.
ZipArchive::FL_ENC_GUESS
Guess string encoding (is default). Available as of PHP 7.0.8.
ZipArchive::FL_ENC_RAW
Get unmodified string. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_STRICT
Follow specification strictly. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_UTF_8
String is UTF-8 encoded. Available as of PHP 7.0.8.
ZipArchive::FL_ENC_CP437
String is CP437 encoded. Available as of PHP 7.0.8.
ZipArchive::FL_OPEN_FILE_NOW
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
better of deflate or store.
ZipArchive::CM_STORE
stored (uncompressed).
ZipArchive::CM_SHRINK
shrunk
ZipArchive::CM_REDUCE_1
reduced with factor 1
ZipArchive::CM_REDUCE_2
reduced with factor 2
ZipArchive::CM_REDUCE_3
reduced with factor 3
ZipArchive::CM_REDUCE_4
reduced with factor 4
ZipArchive::CM_IMPLODE
imploded
ZipArchive::CM_DEFLATE
deflated
ZipArchive::CM_DEFLATE64
deflate64
ZipArchive::CM_PKWARE_IMPLODE
PKWARE imploding
ZipArchive::CM_BZIP2
BZIP2 algorithm
ZipArchive::CM_LZMA
LZMA algorithm
ZipArchive::CM_LZMA2
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
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
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
ZipArchive::CM_LZ77
ZipArchive::CM_WAVPACK
ZipArchive::CM_PPMD
Errors
ZipArchive::ER_OK
No error.
ZipArchive::ER_MULTIDISK
Multi-disk zip archives not supported.
ZipArchive::ER_RENAME
Renaming temporary file failed.
ZipArchive::ER_CLOSE
Closing zip archive failed
ZipArchive::ER_SEEK
Seek error
ZipArchive::ER_READ
Read error
ZipArchive::ER_WRITE
Write error
ZipArchive::ER_CRC
CRC error
ZipArchive::ER_ZIPCLOSED
Containing zip archive was closed
ZipArchive::ER_NOENT
No such file.
ZipArchive::ER_EXISTS
File already exists
ZipArchive::ER_OPEN
Can't open file
ZipArchive::ER_TMPOPEN
Failure to create temporary file.
ZipArchive::ER_ZLIB
Zlib error
ZipArchive::ER_MEMORY
Memory allocation failure
ZipArchive::ER_CHANGED
Entry has been changed
ZipArchive::ER_COMPNOTSUPP
Compression method not supported.
ZipArchive::ER_EOF
Premature EOF
ZipArchive::ER_INVAL
Invalid argument
ZipArchive::ER_NOZIP
Not a zip archive
ZipArchive::ER_INTERNAL
Internal error
ZipArchive::ER_INCONS
Zip archive inconsistent
ZipArchive::ER_REMOVE
Can't remove file
ZipArchive::ER_DELETED
Entry has been deleted
ZipArchive::ER_ENCRNOTSUPP
Encryption method not supported. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_RDONLY
Read-only archive. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_NOPASSWD
No password provided. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_WRONGPASSWD
Wrong password provided. Available as of PHP 7.4.3 and PECL zip 1.16.1, respectively.
ZipArchive::ER_OPNOTSUPP
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
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
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
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
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
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
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
No encryption. Available as of PHP 7.2.0 and PECL zip 1.14.0, respectively.
ZipArchive::EM_TRAD_PKWARE
Traditional PKWARE encryption. Available as of PHP 8.0.0 and PECL zip 1.19.0, respectively.
ZipArchive::EM_AES_128
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
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
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
Unknown encryption algorithm. Available as of PHP 8.0.0 and PECL zip 1.19.0, respectively.
Length parameter constants
ZipArchive::LENGTH_TO_END
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
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
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
ZipArchive::OPSYS_AMIGA
ZipArchive::OPSYS_OPENVMS
ZipArchive::OPSYS_UNIX
ZipArchive::OPSYS_VM_CMS
ZipArchive::OPSYS_ATARI_ST
ZipArchive::OPSYS_OS_2
ZipArchive::OPSYS_MACINTOSH
ZipArchive::OPSYS_Z_SYSTEM
ZipArchive::OPSYS_CPM
ZipArchive::OPSYS_WINDOWS_NTFS
ZipArchive::OPSYS_MVS
ZipArchive::OPSYS_VSE
ZipArchive::OPSYS_ACORN_RISC
ZipArchive::OPSYS_VFAT
ZipArchive::OPSYS_ALTERNATE_MVS
ZipArchive::OPSYS_BEOS
ZipArchive::OPSYS_TANDEM
ZipArchive::OPSYS_OS_400
ZipArchive::OPSYS_OS_X
ZipArchive::OPSYS_DEFAULT
Since PECL zip 1.12.4
add a note

User Contributed Notes 2 notes

up
46
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
5
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