From eca42d118e439dc0f3796650e8a68992d513f8ee Mon Sep 17 00:00:00 2001 From: Paul Duncan <pabs@pablotron.org> Date: Mon, 3 Sep 2018 07:12:40 -0400 Subject: add examples/{10,11,12,13}*php, add examples/*zip to .gitignore --- examples/10-archive_comment.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/10-archive_comment.php (limited to 'examples/10-archive_comment.php') diff --git a/examples/10-archive_comment.php b/examples/10-archive_comment.php new file mode 100644 index 0000000..cc68f2d --- /dev/null +++ b/examples/10-archive_comment.php @@ -0,0 +1,20 @@ +<?php +declare(strict_types = 1); + +require_once __DIR__ . '/../src/ZipStream.php'; + +# import zipstream classes +use Pablotron\ZipStream\ZipStream; +use Pablotron\ZipStream\FileWriter; + +$zip_path = __DIR__ . '/example-10.zip'; + +# create archive in this directory with a comment +ZipStream::send($zip_path, function(ZipStream &$zip) { + # add a file named "hello.txt" to output archive, containing + # the string "hello world!" + $zip->add_file('hello.txt', 'hello world!'); +}, [ + 'comment' => 'example archive comment', + 'output' => new FileWriter(), +]); -- cgit v1.2.3