1<?php 2 3copy('test_with_comment.zip', 't.zip'); 4$z = new ZipArchive; 5$z->open('t.zip'); 6 7print_r($z); 8 9for ($i=0; $i<$z->numFiles; $i++) { 10 echo "index: $i\n"; 11 print_r($z->getCommentIndex($i)); 12 echo "\n\n"; 13} 14echo "foobar/ " . $z->getCommentName('foobar/') . "\n"; 15 16echo "Archive comment: " . $z->getArchiveComment() . "\n"; 17 18 19$z->setCommentIndex(1, 'new comment idx 1'); 20$z->setCommentName('foobar/', 'new comment foobar/'); 21 22$z->setArchiveComment( 'new archive comment'); 23 24for ($i=0; $i<$z->numFiles; $i++) { 25 echo "index: $i\n"; 26 print_r($z->getCommentIndex($i)); 27 echo "\n\n"; 28} 29 30echo $z->getCommentName('foobar/') . "\n"; 31 32// Get the original comment 33echo $z->getCommentName('foobar/', ZIPARCHIVE::FL_UNCHANGED) . "\n"; 34 35echo "Archive comment: " . $z->getArchiveComment() . "\n"; 36echo "Archive comment (original): " . $z->getArchiveComment(ZIPARCHIVE::FL_UNCHANGED) . "\n"; 37