Php &引用;无效或单元化的Zip对象“;关闭DOCX文件时出错
当我尝试使用此代码对.docx文件中的页面进行计数时,我总是收到以下错误: “警告:ZipArchive::close():中的Zip对象无效或单元化”Php &引用;无效或单元化的Zip对象“;关闭DOCX文件时出错,php,docx,Php,Docx,当我尝试使用此代码对.docx文件中的页面进行计数时,我总是收到以下错误: “警告:ZipArchive::close():中的Zip对象无效或单元化” 怎么了?代码中有两个zip关闭,第二个将生成错误,因为您已经关闭了zip function PageCount_DOCX($file) { $pageCount = 0; $zip = new ZipArchive(); if($zip->open($file) === true) { if((
怎么了?代码中有两个zip关闭,第二个将生成错误,因为您已经关闭了zip
function PageCount_DOCX($file) {
$pageCount = 0;
$zip = new ZipArchive();
if($zip->open($file) === true) {
if(($index = $zip->locateName('docProps/app.xml')) !== false) {
$data = $zip->getFromIndex($index);
// remove this one
//$zip->close();
$xml = new SimpleXMLElement($data);
$pageCount = $xml->Pages;
}
// or remove this one
$zip->close();
}
return $pageCount;
}
function PageCount_DOCX($file) {
$pageCount = 0;
$zip = new ZipArchive();
if($zip->open($file) === true) {
if(($index = $zip->locateName('docProps/app.xml')) !== false) {
$data = $zip->getFromIndex($index);
// remove this one
//$zip->close();
$xml = new SimpleXMLElement($data);
$pageCount = $xml->Pages;
}
// or remove this one
$zip->close();
}
return $pageCount;
}