function zip_files(string $zipName,...$files){
//检测压缩包名称是否正确
$zipExt=strtolower(pathinfo($zipName,PATHINFO_EXTENSION));
if('zip'!==$zipExt){
return false;
}
$zip=new ZipArchive();
if($zip->open($zipName,ZipArchive::CREATE|ZipArchive::OVERWRITE)){
foreach($files as $file){
if(is_file($file)){
$zip->addFile($file);
}
}
$zip->close();
return true;
}else{
return false;
}
}
//检测压缩包名称是否正确
$zipExt=strtolower(pathinfo($zipName,PATHINFO_EXTENSION));
if('zip'!==$zipExt){
return false;
}
$zip=new ZipArchive();
if($zip->open($zipName,ZipArchive::CREATE|ZipArchive::OVERWRITE)){
foreach($files as $file){
if(is_file($file)){
$zip->addFile($file);
}
}
$zip->close();
return true;
}else{
return false;
}
}