xref: /PHP-8.3/ext/zip/tests/oo_stream.phpt (revision 74859783)
1--TEST--
2getStream
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7$dirname = __DIR__ . '/';
8$file = $dirname . 'test_with_comment.zip';
9include $dirname . 'utils.inc';
10$zip = new ZipArchive;
11if (!$zip->open($file)) {
12    exit('failed');
13}
14$fp = $zip->getStream('foo');
15
16var_dump($fp);
17if(!$fp) exit("\n");
18$contents = '';
19while (!feof($fp)) {
20    $contents .= fread($fp, 255);
21}
22
23fclose($fp);
24$zip->close();
25var_dump($contents);
26
27
28$fp = fopen('zip://' . __DIR__ . '/test_with_comment.zip#foo', 'rb');
29if (!$fp) {
30  exit("cannot open\n");
31}
32$contents = '';
33while (!feof($fp)) {
34  $contents .= fread($fp, 2);
35}
36var_dump($contents);
37fclose($fp);
38
39?>
40--EXPECTF--
41resource(%d) of type (stream)
42string(5) "foo
43
44"
45string(5) "foo
46
47"
48