xref: /PHP-8.3/ext/zlib/tests/gzreadgzwrite.phpt (revision 74859783)
1--TEST--
2gzopen(), gzread(), gzwrite()
3--EXTENSIONS--
4zlib
5--FILE--
6<?php
7$original = str_repeat("hallo php",4096);
8$filename = tempnam(sys_get_temp_dir(), "phpt");
9
10$fp = gzopen($filename, "wb");
11gzwrite($fp, $original);
12var_dump(strlen($original));
13var_dump(gztell($fp));
14fclose($fp);
15
16$fp = gzopen($filename, "rb");
17
18$data = '';
19while ($buf = gzread($fp, 8092)) {
20    $data .= $buf;
21}
22
23if ($data == $original) {
24    echo "Strings are equal\n";
25} else {
26    echo "Strings are not equal\n";
27    var_dump($data);
28}
29gzclose($fp);
30unlink($filename);
31?>
32--EXPECT--
33int(36864)
34int(36864)
35Strings are equal
36