xref: /PHP-5.4/ext/zip/examples/fopen.php (revision b734bf4b)
1<?php
2if (!extension_loaded('zip')) {
3    dl('zip.so');
4}
5
6
7$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
8if (!$fp) {
9	exit("cannot open\n");
10}
11while (!feof($fp)) {
12	$contents .= fread($fp, 2);
13	echo "$contents\n";
14}
15
16fclose($fp);
17echo "done.\n";
18
19
20$content = '';
21$z = new ZipArchive();
22$z->open(dirname(__FILE__) . '/test.zip');
23$fp = $z->getStream('test');
24
25var_dump($fp);
26if(!$fp) exit("\n");
27while (!feof($fp)) {
28	$contents .= fread($fp, 2);
29}
30
31fclose($fp);
32file_put_contents('t',$contents);
33echo "done.\n";
34
35
36