class ZipArchive implements Countable (View source)

A file archive, compressed with Zip.

Constants

LIBZIP_VERSION Since: 7.4.3

Zip library version

CREATE

Create the archive if it does not exist.

EXCL

Error if archive already exists.

CHECKCONS

Perform additional consistency checks on the archive, and error if they fail.

OVERWRITE

Always start a new archive, this mode will overwrite the file if it already exists.

FL_NOCASE

Ignore case on name lookup

FL_NODIR

Ignore directory component

FL_COMPRESSED

Read compressed data

FL_UNCHANGED

Use original data, ignoring changes.

FL_RECOMPRESS

FL_ENCRYPTED

FL_OVERWRITE

FL_LOCAL

FL_CENTRAL

EM_TRAD_PKWARE

EM_UNKNOWN

CM_DEFAULT

better of deflate or store.

CM_STORE

stored (uncompressed).

CM_SHRINK

shrunk

CM_REDUCE_1

reduced with factor 1

CM_REDUCE_2

reduced with factor 2

CM_REDUCE_3

reduced with factor 3

CM_REDUCE_4

reduced with factor 4

CM_IMPLODE

imploded

CM_DEFLATE

deflated

CM_DEFLATE64

deflate64

CM_PKWARE_IMPLODE

PKWARE imploding

CM_BZIP2

BZIP2 algorithm

CM_LZMA

CM_TERSE

CM_LZ77

CM_WAVPACK

CM_PPMD

ER_OK

No error.

ER_MULTIDISK

Multi-disk zip archives not supported.

ER_RENAME

Renaming temporary file failed.

ER_CLOSE

Closing zip archive failed

ER_SEEK

Seek error

ER_READ

Read error

ER_WRITE

Write error

ER_CRC

CRC error

ER_ZIPCLOSED

Containing zip archive was closed

ER_NOENT

No such file.

ER_EXISTS

File already exists

ER_OPEN

Can't open file

ER_TMPOPEN

Failure to create temporary file.

ER_ZLIB

Zlib error

ER_MEMORY

Memory allocation failure

ER_CHANGED

Entry has been changed

ER_COMPNOTSUPP

Compression method not supported.

ER_EOF

Premature EOF

ER_INVAL

Invalid argument

ER_NOZIP

Not a zip archive

ER_INTERNAL

Internal error

ER_INCONS

Zip archive inconsistent

ER_REMOVE

Can't remove file

ER_DELETED

Entry has been deleted

EM_NONE Since: 7.2

No encryption

EM_AES_128 Since: 7.2

AES 128 encryption

EM_AES_192 Since: 7.2

AES 192 encryption

EM_AES_256 Since: 7.2

AES 256 encryption

RDONLY Since: 7.4.3

Open archive in read only mode

FL_ENC_GUESS Since: 7.0.8

Guess string encoding (is default)

FL_ENC_RAW Since: 7.0.8

Get unmodified string

FL_ENC_STRICT Since: 7.0.8

Follow specification strictly

FL_ENC_UTF_8 Since: 7.0.8

String is UTF-8 encoded

FL_ENC_CP437 Since: 7.0.8

String is CP437 encoded

CM_LZMA2 Since: 7.4.3

LZMA2 algorithm

CM_XZ Since: 7.4.3

XZ algorithm

ER_ENCRNOTSUPP Since: 7.4.3

Encryption method not support

ER_RDONLY Since: 7.4.3

Read-only archive

ER_NOPASSWD Since: 7.4.3

No password provided

ER_WRONGPASSWD Since: 7.4.3

Wrong password provided

ER_OPNOTSUPP Since: 7.4.3

Operation not supported

ER_INUSE Since: 7.4.3

Resource still in use

ER_TELL Since: 7.4.3

Tell error

ER_COMPRESSED_DATA Since: 7.4.3

Compressed data invalid

ER_CANCELLED Since: 7.4.3

Operation cancelled

OPSYS_DOS Since: 5.6

OPSYS_AMIGA Since: 5.6

OPSYS_OPENVMS Since: 5.6

OPSYS_UNIX Since: 5.6

OPSYS_VM_CMS Since: 5.6

OPSYS_ATARI_ST Since: 5.6

OPSYS_OS_2 Since: 5.6

OPSYS_MACINTOSH Since: 5.6

OPSYS_Z_SYSTEM Since: 5.6

OPSYS_Z_CPM Since: 5.6

OPSYS_WINDOWS_NTFS Since: 5.6

OPSYS_MVS Since: 5.6

OPSYS_VSE Since: 5.6

OPSYS_ACORN_RISC Since: 5.6

OPSYS_VFAT Since: 5.6

OPSYS_ALTERNATE_MVS Since: 5.6

OPSYS_BEOS Since: 5.6

OPSYS_TANDEM Since: 5.6

OPSYS_OS_400 Since: 5.6

OPSYS_OS_X Since: 5.6

OPSYS_CPM

OPSYS_DEFAULT Since: 5.6

FL_OPEN_FILE_NOW

CM_ZSTD

ER_DATA_LENGTH

ER_NOT_ALLOWED

AFL_RDONLY

AFL_IS_TORRENTZIP

AFL_WANT_TORRENTZIP

AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE

LENGTH_TO_END

LENGTH_UNCHECKED

Properties

int $status

Status of the Zip Archive

int $statusSys

System status of the Zip Archive

int $numFiles

Number of files in archive

string $filename

File name in the file system

string $comment

Comment for the archive

int $lastId

Methods

int|bool
open(string $filename, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Open a ZIP file archive

bool
close()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Close the active archive (opened or newly created)

int
count()

(PHP 7 >= 7.2.0, PECL zip >= 1.15.0)
Counts the number of files in the archive.

string
getStatusString()

Returns the status error message, system and/or zip messages

bool
addEmptyDir(string $dirname, int $flags)

(PHP 5 >= 5.2.0, PECL zip >= 1.8.0)
Add a new directory

bool
addFromString(string $name, string $content, int $flags = 8192)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Add a file to a ZIP archive using its contents

bool
addFile(string $filepath, string $entryname = null, int $start = 0, int $length = 0, int $flags = 8192)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Adds a file to a ZIP archive from the given path

array|false
addGlob(string $pattern, int $flags = 0, array $options = [])

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by glob pattern

array|false
addPattern(string $pattern, string $path = '.', array $options = [])

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by PCRE pattern

bool
renameIndex(int $index, string $new_name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its index

bool
renameName(string $name, string $new_name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its name

bool
setArchiveComment(string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of a ZIP archive

string|false
getArchiveComment(int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the Zip archive comment

bool
setCommentIndex(int $index, string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its index

bool
setCommentName(string $name, string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its name

bool
setCompressionIndex(int $index, int $method, int $compflags = 0)

Set the compression method of an entry defined by its index

bool
setCompressionName(string $name, int $method, int $compflags = 0)

Set the compression method of an entry defined by its name https://secure.php.net/manual/en/ziparchive.setcompressionname.php

bool
setEncryptionIndex(int $index, int $method, string|null $password = null)

Set the encryption method of an entry defined by its index

bool
setEncryptionName(string $name, int $method, string|null $password = null)

Set the encryption method of an entry defined by its name

bool
setPassword(string $password)

(PHP 5 >= 5.6.0, PECL zip >= 1.12.0)

string|false
getCommentIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry index

string|false
getCommentName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry name

bool
deleteIndex(int $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its index

bool
deleteName(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its name

array|false
statName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Get the details of an entry defined by its name.

array|false
statIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get the details of an entry defined by its index.

int|false
locateName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the index of the entry in the archive

string|false
getNameIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the name of an entry using its index

bool
unchangeArchive()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all global changes done in the archive.

bool
unchangeAll()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Undo all changes done in the archive

bool
unchangeIndex(int $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all changes done to an entry at the given index

bool
unchangeName(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Revert all changes done to an entry with the given name.

bool
extractTo(string $pathto, string[]|string|null $files = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Extract the archive contents

string|false
getFromName(string $name, int $len = 0, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the entry contents using its name

string|false
getFromIndex(int $index, int $len = 0, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.3.0)
Returns the entry contents using its index

resource|false
getStream(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get a file handler to the entry defined by its name (read only).

resource|false
getStreamIndex(int $index, int $flags = 0)

(PHP 8 >= 8.2.0, PECL zip >= 1.20.0)
Get a file handler to the entry defined by its index (read only)

bool
setExternalAttributesName(string $name, int $opsys, int $attr, int $flags = null)

Set the external attributes of an entry defined by its name

bool
getExternalAttributesName(string $name, int $opsys, int $attr, int $flags = null)

Retrieve the external attributes of an entry defined by its name

bool
setExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = null)

Set the external attributes of an entry defined by its index

bool
getExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = null)

Retrieve the external attributes of an entry defined by its index

static 
isEncryptionMethodSupported($method, $enc = true)

No description

static 
isCompressionMethodSupported($method, $enc = true)

No description

bool
registerCancelCallback($callback)

No description

bool
registerProgressCallback($rate, $callback)

No description

bool
setMtimeName($name, $timestamp, $flags = null)

No description

bool
setMtimeIndex($index, $timestamp, $flags = null)

No description

bool
replaceFile($filepath, $index, $start = null, $length = null, $flags = null)

No description

clearError()

No description

bool
setArchiveFlag(int $flag, int $value)

No description

int
getArchiveFlag(int $flag, int $flags = 0)

No description

void
getStreamName(string $name, int $flags = 0)

No description

Details

int|bool open(string $filename, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Open a ZIP file archive

Parameters

string $filename

The file name of the ZIP archive to open.

int $flags

[optional]

The mode to use to open the archive.

ZipArchive::OVERWRITE

Return Value

int|bool

Error codes

Returns TRUE on success, FALSE or the error code on error.

ZipArchive::ER_EXISTS

File already exists.

ZipArchive::ER_INCONS

Zip archive inconsistent.

ZipArchive::ER_INVAL

Invalid argument.

ZipArchive::ER_MEMORY

Malloc failure.

ZipArchive::ER_NOENT

No such file.

ZipArchive::ER_NOZIP

Not a zip archive.

ZipArchive::ER_OPEN

Can't open file.

ZipArchive::ER_READ

Read error.

ZipArchive::ER_SEEK

Seek error.

bool close()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Close the active archive (opened or newly created)

Return Value

bool

TRUE on success or FALSE on failure.

int count()

Since: 7.2

(PHP 7 >= 7.2.0, PECL zip >= 1.15.0)
Counts the number of files in the archive.

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

string getStatusString()

Since: 5.2.7

Returns the status error message, system and/or zip messages

Return Value

string

a string with the status message on success or FALSE on failure.

bool addEmptyDir(string $dirname, int $flags)

(PHP 5 >= 5.2.0, PECL zip >= 1.8.0)
Add a new directory

Parameters

string $dirname

The directory to add.

int $flags

[optional] Set how to manage name encoding (ZipArchive::FLENC*) and entry replacement (ZipArchive::FL_OVERWRITE)

Return Value

bool

TRUE on success or FALSE on failure.

bool addFromString(string $name, string $content, int $flags = 8192)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Add a file to a ZIP archive using its contents

Parameters

string $name

The name of the entry to create.

string $content

The contents to use to create the entry. It is used in a binary safe mode.

int $flags

[optional] Set how to manage name encoding (ZipArchive::FLENC*) and entry replacement (ZipArchive::FL_OVERWRITE)

Return Value

bool

TRUE on success or FALSE on failure.

bool addFile(string $filepath, string $entryname = null, int $start = 0, int $length = 0, int $flags = 8192)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Adds a file to a ZIP archive from the given path

Parameters

string $filepath

The path to the file to add.

string $entryname

[optional]

If supplied, this is the local name inside the ZIP archive that will override the filename.

int $start

[optional]

This parameter is not used but is required to extend ZipArchive.

int $length

[optional]

This parameter is not used but is required to extend ZipArchive.

int $flags

[optional] Set how to manage name encoding (ZipArchive::FLENC*) and entry replacement (ZipArchive::FL_OVERWRITE)

Return Value

bool

TRUE on success or FALSE on failure.

array|false addGlob(string $pattern, int $flags = 0, array $options = [])

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by glob pattern

Parameters

string $pattern

A glob pattern against which files will be matched.

int $flags

[optional]

A bit mask of glob() flags.

array $options

[optional]

An associative array of options. Available options are:

"add_path"

Prefix to prepend when translating to the local path of the file within the archive. This is applied after any remove operations defined by the "remove_path" or "remove_all_path" options.

Return Value

array|false

array|false addPattern(string $pattern, string $path = '.', array $options = [])

(PHP 5 >= 5.3.0, PECL zip >= 1.9.0)
Add files from a directory by PCRE pattern

Parameters

string $pattern

A PCRE pattern against which files will be matched.

string $path

[optional]

The directory that will be scanned. Defaults to the current working directory.

array $options

[optional]

An associative array of options accepted by ZipArchive::addGlob.

Return Value

array|false

bool renameIndex(int $index, string $new_name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its index

Parameters

int $index

Index of the entry to rename.

string $new_name

New name.

Return Value

bool

TRUE on success or FALSE on failure.

bool renameName(string $name, string $new_name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Renames an entry defined by its name

Parameters

string $name

Name of the entry to rename.

string $new_name

New name.

Return Value

bool

TRUE on success or FALSE on failure.

bool setArchiveComment(string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of a ZIP archive

Parameters

string $comment

The contents of the comment.

Return Value

bool

TRUE on success or FALSE on failure.

string|false getArchiveComment(int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the Zip archive comment

Parameters

int $flags

[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Return Value

string|false

the Zip archive comment or FALSE on failure.

bool setCommentIndex(int $index, string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its index

Parameters

int $index

Index of the entry.

string $comment

The contents of the comment.

Return Value

bool

TRUE on success or FALSE on failure.

bool setCommentName(string $name, string $comment)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Set the comment of an entry defined by its name

Parameters

string $name

Name of the entry.

string $comment

The contents of the comment.

Return Value

bool

TRUE on success or FALSE on failure.

bool setCompressionIndex(int $index, int $method, int $compflags = 0)

Since: 7.0

Set the compression method of an entry defined by its index

Parameters

int $index

Index of the entry.

int $method

The compression method. Either ZipArchive::CM_DEFAULT, ZipArchive::CM_STORE or ZipArchive::CM_DEFLATE.

int $compflags

[optional] Compression flags. Currently unused.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool setCompressionName(string $name, int $method, int $compflags = 0)

Since: 7.0

Set the compression method of an entry defined by its name https://secure.php.net/manual/en/ziparchive.setcompressionname.php

Parameters

string $name

Name of the entry.

int $method

The compression method. Either ZipArchive::CM_DEFAULT, ZipArchive::CM_STORE or ZipArchive::CM_DEFLATE.

int $compflags

[optional] Compression flags. Currently unused.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool setEncryptionIndex(int $index, int $method, string|null $password = null)

Since: 7.2

Set the encryption method of an entry defined by its index

Parameters

int $index

Index of the entry.

int $method

The encryption method defined by one of the ZipArchive::EM_ constants.

string|null $password

[optional] Optional password, default used when missing.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool setEncryptionName(string $name, int $method, string|null $password = null)

Since: 7.2

Set the encryption method of an entry defined by its name

Parameters

string $name

Name of the entry.

int $method

The encryption method defined by one of the ZipArchive::EM_ constants.

string|null $password

[optional] Optional password, default used when missing.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool setPassword(string $password)

(PHP 5 >= 5.6.0, PECL zip >= 1.12.0)

Parameters

string $password

Return Value

bool

string|false getCommentIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry index

Parameters

int $index

Index of the entry

int $flags

[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Return Value

string|false

the comment on success or FALSE on failure.

string|false getCommentName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.4.0)
Returns the comment of an entry using the entry name

Parameters

string $name

Name of the entry

int $flags

[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged comment is returned.

Return Value

string|false

the comment on success or FALSE on failure.

bool deleteIndex(int $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its index

Parameters

int $index

Index of the entry to delete.

Return Value

bool

TRUE on success or FALSE on failure.

bool deleteName(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
delete an entry in the archive using its name

Parameters

string $name

Name of the entry to delete.

Return Value

bool

TRUE on success or FALSE on failure.

array|false statName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Get the details of an entry defined by its name.

Parameters

string $name

Name of the entry

int $flags

[optional]

The flags argument specifies how the name lookup should be done. Also, ZipArchive::FL_UNCHANGED may be ORed to it to request information about the original file in the archive, ignoring any changes made. ZipArchive::FL_NOCASE

Return Value

array|false

array|false statIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get the details of an entry defined by its index.

Parameters

int $index

Index of the entry

int $flags

[optional]

ZipArchive::FL_UNCHANGED may be ORed to it to request information about the original file in the archive, ignoring any changes made.

Return Value

array|false

int|false locateName(string $name, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the index of the entry in the archive

Parameters

string $name

The name of the entry to look up

int $flags

[optional]

The flags are specified by ORing the following values, or 0 for none of them. ZipArchive::FL_NOCASE

Return Value

int|false

the index of the entry on success or FALSE on failure.

string|false getNameIndex(int $index, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Returns the name of an entry using its index

Parameters

int $index

Index of the entry.

int $flags

[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged name is returned.

Return Value

string|false

the name on success or FALSE on failure.

bool unchangeArchive()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all global changes done in the archive.

Return Value

bool

TRUE on success or FALSE on failure.

bool unchangeAll()

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Undo all changes done in the archive

Return Value

bool

TRUE on success or FALSE on failure.

bool unchangeIndex(int $index)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Revert all changes done to an entry at the given index

Parameters

int $index

Index of the entry.

Return Value

bool

TRUE on success or FALSE on failure.

bool unchangeName(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)
Revert all changes done to an entry with the given name.

Parameters

string $name

Name of the entry.

Return Value

bool

TRUE on success or FALSE on failure.

bool extractTo(string $pathto, string[]|string|null $files = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Extract the archive contents

Parameters

string $pathto

Location where to extract the files.

string[]|string|null $files

[optional]

The entries to extract. It accepts either a single entry name or an array of names.

Return Value

bool

TRUE on success or FALSE on failure.

string|false getFromName(string $name, int $len = 0, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Returns the entry contents using its name

Parameters

string $name

Name of the entry

int $len

[optional]

The length to be read from the entry. If 0, then the entire entry is read.

int $flags

[optional]

The flags to use to open the archive. the following values may be ORed to it. ZipArchive::FL_UNCHANGED

Return Value

string|false

the contents of the entry on success or FALSE on failure.

string|false getFromIndex(int $index, int $len = 0, int $flags = null)

(PHP 5 >= 5.2.0, PECL zip >= 1.3.0)
Returns the entry contents using its index

Parameters

int $index

Index of the entry

int $len

[optional]

The length to be read from the entry. If 0, then the entire entry is read.

int $flags

[optional]

The flags to use to open the archive. the following values may be ORed to it.

ZipArchive::FL_UNCHANGED

Return Value

string|false

the contents of the entry on success or FALSE on failure.

resource|false getStream(string $name)

(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)
Get a file handler to the entry defined by its name (read only).

Parameters

string $name

The name of the entry to use.

Return Value

resource|false

a file pointer (resource) on success or FALSE on failure.

resource|false getStreamIndex(int $index, int $flags = 0)

(PHP 8 >= 8.2.0, PECL zip >= 1.20.0)
Get a file handler to the entry defined by its index (read only)

Parameters

int $index

Index of the entry

int $flags

[optional]

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged stream is returned.

Return Value

resource|false

a file pointer (resource) on success or FALSE on failure.

bool setExternalAttributesName(string $name, int $opsys, int $attr, int $flags = null)

Set the external attributes of an entry defined by its name

Parameters

string $name

Name of the entry

int $opsys

The operating system code defined by one of the ZipArchive::OPSYS_ constants.

int $attr

The external attributes. Value depends on operating system.

int $flags

[optional] Optional flags. Currently unused.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool getExternalAttributesName(string $name, int $opsys, int $attr, int $flags = null)

Retrieve the external attributes of an entry defined by its name

Parameters

string $name

Name of the entry

int $opsys

On success, receive the operating system code defined by one of the ZipArchive::OPSYS_ constants.

int $attr

On success, receive the external attributes. Value depends on operating system.

int $flags

[optional] If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged attributes are returned.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool setExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = null)

Set the external attributes of an entry defined by its index

Parameters

int $index

Index of the entry.

int $opsys

The operating system code defined by one of the ZipArchive::OPSYS_ constants.

int $attr

The external attributes. Value depends on operating system.

int $flags

[optional] Optional flags. Currently unused.

Return Value

bool

Returns TRUE on success or FALSE on failure.

bool getExternalAttributesIndex(int $index, int $opsys, int $attr, int $flags = null)

Retrieve the external attributes of an entry defined by its index

Parameters

int $index

Index of the entry.

int $opsys

On success, receive the operating system code defined by one of the ZipArchive::OPSYS_ constants.

int $attr

On success, receive the external attributes. Value depends on operating system.

int $flags

[optional] If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged attributes are returned.

Return Value

bool

Returns TRUE on success or FALSE on failure.

static isEncryptionMethodSupported($method, $enc = true)

No description

Parameters

$method
$enc

static isCompressionMethodSupported($method, $enc = true)

No description

Parameters

$method
$enc

bool registerCancelCallback($callback)

No description

Parameters

$callback

Return Value

bool

bool registerProgressCallback($rate, $callback)

No description

Parameters

$rate
$callback

Return Value

bool

bool setMtimeName($name, $timestamp, $flags = null)

No description

Parameters

$name
$timestamp
$flags

Return Value

bool

bool setMtimeIndex($index, $timestamp, $flags = null)

No description

Parameters

$index
$timestamp
$flags

Return Value

bool

bool replaceFile($filepath, $index, $start = null, $length = null, $flags = null)

No description

Parameters

$filepath
$index
$start
$length
$flags

Return Value

bool

clearError()

No description

bool setArchiveFlag(int $flag, int $value)

No description

Parameters

int $flag
int $value

Return Value

bool

int getArchiveFlag(int $flag, int $flags = 0)

No description

Parameters

int $flag
int $flags

Return Value

int

void getStreamName(string $name, int $flags = 0)

No description

Parameters

string $name
int $flags

Return Value

void