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