array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'ziparchive.setpassword.php', 1 => 'ZipArchive::setPassword', 2 => 'Set the password for the active archive', ), 'up' => array ( 0 => 'class.ziparchive.php', 1 => 'ZipArchive', ), 'prev' => array ( 0 => 'ziparchive.setmtimename.php', 1 => 'ZipArchive::setMtimeName', ), 'next' => array ( 0 => 'ziparchive.statindex.php', 1 => 'ZipArchive::statIndex', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/zip/ziparchive/setpassword.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

ZipArchive::setPassword

(PHP 5 >= 5.6.0, PHP 7, PHP 8, PECL zip >= 1.12.4)

ZipArchive::setPasswordSet the password for the active archive

说明

public ZipArchive::setPassword(#[\SensitiveParameter] string $password): bool

Sets the password for the active archive.

参数

password

The password to be used for the archive.

返回值

成功时返回 true, 或者在失败时返回 false

注释

注意:

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.

参见