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