summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/gzseek_variation5.phpt
blob: 41d5c777a6883af5daa7cc12eafded95ba8710f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--TEST--
Test function gzseek() by calling it with SEEK_CUR when writing
--SKIPIF--
<?php
if (!extension_loaded("zlib")) {
    print "skip - ZLIB extension not loaded";
}
?>
--FILE--
<?php
$f = "gzseek_variation5.gz";
$h = gzopen($f, 'w');
$str1 = "This is the first line.";
$str2 = "This is the second line.";
gzwrite($h, $str1);
echo "tell=".gztell($h)."\n";

//seek forwards 20 bytes.
gzseek($h, 20, SEEK_CUR);
echo "tell=".gztell($h)."\n";
gzwrite($h, $str2);
echo "tell=".gztell($h)."\n";
gzclose($h);
echo "\nreading the output file\n";
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."\n";
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."\n";
gzclose($h);
unlink($f);
?>
--EXPECT--
tell=23
tell=43
tell=67

reading the output file
This is the first line.
string(40) "0000000000000000000000000000000000000000"
This is the second line.