ZipArchive::setPassword

Set the password for the active archive

&reftitle.description; public `bool` `ZipArchive::setPassword` `string` `password`

Sets the password for the active archive.

&reftitle.parameters;

`password`

- The password to be used for the archive.

&reftitle.returnvalues;

&return.success;

&reftitle.notes;

As of PHP 7.2.0 and libzip 1.2.0 the password is used to decompress the archive, and is also the default password for `ZipArchive::setEncryptionName` and `ZipArchive::setEncryptionIndex`. Formerly, this function only set the password to be used to decompress the archive; it did not turn a non-password-protected `ZipArchive` into a password-protected `ZipArchive`.

&reftitle.seealso;

- `ZipArchive::setEncryptionIndex`
- `ZipArchive::setEncryptionName`