1<?php
2error_reporting(E_ALL);
3if (!extension_loaded('zip')) {
4    dl('zip.so');
5}
6
7$zip = new ZipArchive();
8$filename = "a.zip";
9
10if (!$zip->open($filename, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) {
11	exit("cannot open <$filename>\n");
12}
13
14$zip->addFromString("testfilephp.txt", "#1 This is a test string added as testfilephp.txt.\n");
15$zip->addFromString("testfilephp2.txt", "#2 This is a test string added as testfilephp2.txt.\n");
16$zip->addFile("too.php", "testfromfile.php");
17
18$zip->setCompressionName("testfilephp2.txt", ZipArchive::CM_STORE);
19$zip->setCompressionIndex(2, ZipArchive::CM_STORE);
20
21$zip->close();
22