ZIP a file and protect with a password in PHP
问题 I'm having this code to zip files but i need to protect this file with a password $file = 'backup.sql'; $zipname = $file.'.zip'; $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE); ZipArchive::setPassword('123456'); //$zip->setPassword("123456"); $zip->addFile($file); $zip->close(); when i use $zip->setPassword i don't get any errors but the file is not protected at all and when i use ZipArchive::setPassword i get this error "Fatal error: Non-static method ZipArchive::setPassword