note 118392 added to class.ziparchive

From: Date: Sat, 28 Nov 2015 18:14:58 +0000
Subject: note 118392 added to class.ziparchive
Groups: php.notes 
Request: Send a blank email to php-notes+get-204239@lists.php.net to get a copy of this message
With PHP 5.6+, you may come up with theses errors. Warning: Unknown: Cannot destroy the zip context in Unknown on line 0 Warning: ZipArchive::close(): Can't remove file: No such file or directory in xxxx.php on line xx Examples Warning: Unknown: Cannot destroy the zip context in Unknown on line 0 <?php $za = new ZipArchive; $za->open('51-n.com.zip',ZipArchive::CREATE|ZipArchive::OVERWRITE); ?> Warning: ZipArchive::close(): Can't remove file: No such file or directory in xxxx.php on line xx <?php $za = new ZipArchive; $za->open('51-n.com.zip',ZipArchive::CREATE|ZipArchive::OVERWRITE); $za->close(); ?> It happens when the zip archive is empty. Your zip archive will not be saved on disk unless it has at least one file. What's more, when ZipArchive::OVERWRITE is applied, if there exists a file with the same name, it will be removed after ZipArchive::open() is called. So, don't forget to put at least one file to your zip archive. <?php $za = new ZipArchive; $za->open('51-n.com.zip',ZipArchive::CREATE|ZipArchive::OVERWRITE); $za->addFromString('wuxiancheng.cn.txt','yes'); $za->close(); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 118.117.63.49 ---- Manual Page -- http://php.net/manual/en/class.ziparchive.php Edit -- https://master.php.net/note/edit/118392 Del: integrated -- https://master.php.net/note/delete/118392/integrated Del: useless -- https://master.php.net/note/delete/118392/useless Del: bad code -- https://master.php.net/note/delete/118392/bad+code Del: spam -- https://master.php.net/note/delete/118392/spam Del: non-english -- https://master.php.net/note/delete/118392/non-english Del: in docs -- https://master.php.net/note/delete/118392/in+docs Del: other reasons-- https://master.php.net/note/delete/118392 Reject -- https://master.php.net/note/reject/118392 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204239) next »