diff options
| author | Remi Collet <remi@fedoraproject.org> | 2015-05-06 15:11:00 +0200 |
|---|---|---|
| committer | Remi Collet <remi@php.net> | 2015-05-06 15:16:43 +0200 |
| commit | 3a55ea02aa0a91bbb90a6db8dda620720d141eb1 (patch) | |
| tree | 8dfd155729cd82074b465e0b8426b9accb5811b5 /ext/zip/examples/set_compression.php | |
| parent | 3638ac2300bc7464b30cf26bf3c7be5beea82503 (diff) | |
| download | php-git-3a55ea02aa0a91bbb90a6db8dda620720d141eb1.tar.gz | |
add ZipArchive::setCompressionName and ZipArchive::setCompressionIndex methods
Diffstat (limited to 'ext/zip/examples/set_compression.php')
| -rw-r--r-- | ext/zip/examples/set_compression.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/zip/examples/set_compression.php b/ext/zip/examples/set_compression.php new file mode 100644 index 0000000000..1efd88c7f1 --- /dev/null +++ b/ext/zip/examples/set_compression.php @@ -0,0 +1,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(); |
