diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/zip/examples/create.php | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/zip/examples/create.php')
-rw-r--r-- | ext/zip/examples/create.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/zip/examples/create.php b/ext/zip/examples/create.php new file mode 100644 index 0000000..a41c8e6 --- /dev/null +++ b/ext/zip/examples/create.php @@ -0,0 +1,23 @@ +<?php +error_reporting(E_ALL); +if (!extension_loaded('zip')) { + dl('zip.so'); +} +$thisdir = dirname(__FILE__); +unlink("./test112.zip"); +$zip = new ZipArchive(); +$filename = "./test112.zip"; + +if (!$zip->open($filename, ZIPARCHIVE::CREATE)) { + exit("cannot open <$filename>\n"); +} else { + echo "file <$filename> OK\n"; +} + +$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n"); +$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n"); +$zip->addFile($thisdir . "/too.php","/testfromfile.php"); +echo "numfiles: " . $zip->numFiles . "\n"; +echo "status:" . $zip->status . "\n"; +$zip->close(); +unset($zip); |