xref: /PHP-8.0/ext/zlib/tests/gzseek_basic2.phpt (revision c5401854)
1--TEST--
2Test function gzseek() by calling it with its expected arguments when writing
3--SKIPIF--
4<?php
5if (!extension_loaded("zlib")) {
6    print "skip - ZLIB extension not loaded";
7}
8?>
9--FILE--
10<?php
11$f = "gzseek_basic2.gz";
12$h = gzopen($f, 'w');
13$str1 = "This is the first line.";
14$str2 = "This is the second line.";
15gzwrite($h, $str1);
16echo "tell=".gztell($h)."\n";
17
18//seek forwards 20 bytes.
19gzseek($h, strlen($str1) + 20);
20echo "tell=".gztell($h)."\n";
21gzwrite($h, $str2);
22echo "tell=".gztell($h)."\n";
23gzclose($h);
24echo "\nreading the output file\n";
25$h = gzopen($f, 'r');
26echo gzread($h, strlen($str1))."\n";
27var_dump(bin2hex(gzread($h, 20)));
28echo gzread($h, strlen($str2))."\n";
29gzclose($h);
30unlink($f);
31?>
32--EXPECT--
33tell=23
34tell=43
35tell=67
36
37reading the output file
38This is the first line.
39string(40) "0000000000000000000000000000000000000000"
40This is the second line.
41