Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Test function gzseek() by calling it with SEEK_CUR when writing --EXTENSIONS-- zl..

Decoded Output download

--TEST--
Test function gzseek() by calling it with SEEK_CUR when writing
--EXTENSIONS--
zlib
--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)."
";

//seek forwards 20 bytes.
gzseek($h, 20, SEEK_CUR);
echo "tell=".gztell($h)."
";
gzwrite($h, $str2);
echo "tell=".gztell($h)."
";
gzclose($h);
echo "
reading the output file
";
$h = gzopen($f, 'r');
echo gzread($h, strlen($str1))."
";
var_dump(bin2hex(gzread($h, 20)));
echo gzread($h, strlen($str2))."
";
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.

Did this file decode correctly?

Original Code

--TEST--
Test function gzseek() by calling it with SEEK_CUR when writing
--EXTENSIONS--
zlib
--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.

Function Calls

gzopen 1

Variables

$f gzseek_variation5.gz

Stats

MD5 d180cadc1e69b5efc5e9ce6a11eeec05
Eval Count 0
Decode Time 80 ms