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

There are no user contributed notes for this page.
To Top