gzseek_variation5.phpt 784 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Test function gzseek() by calling it with SEEK_CUR when writing
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. $f = "gzseek_variation5.gz";
  8. $h = gzopen($f, 'w');
  9. $str1 = "This is the first line.";
  10. $str2 = "This is the second line.";
  11. gzwrite($h, $str1);
  12. echo "tell=".gztell($h)."\n";
  13. //seek forwards 20 bytes.
  14. gzseek($h, 20, SEEK_CUR);
  15. echo "tell=".gztell($h)."\n";
  16. gzwrite($h, $str2);
  17. echo "tell=".gztell($h)."\n";
  18. gzclose($h);
  19. echo "\nreading the output file\n";
  20. $h = gzopen($f, 'r');
  21. echo gzread($h, strlen($str1))."\n";
  22. var_dump(bin2hex(gzread($h, 20)));
  23. echo gzread($h, strlen($str2))."\n";
  24. gzclose($h);
  25. unlink($f);
  26. ?>
  27. --EXPECT--
  28. tell=23
  29. tell=43
  30. tell=67
  31. reading the output file
  32. This is the first line.
  33. string(40) "0000000000000000000000000000000000000000"
  34. This is the second line.