创建时,只需将所需的目标路径传递给zip:
$path = 'path/to/file.zip'; $zip = new ZipArchive(); $zip->open($path,ZipArchive::CREATE); // add contents... $zip->close();