gzseek_variation1.phpt 607 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Test function gzseek() by seeking forward in write mode
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. $f = "gzseek_variation1.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. //seek forwards 20 bytes.
  13. gzseek($h, strlen($str1) + 20);
  14. gzwrite($h, $str2);
  15. gzclose($h);
  16. $h = gzopen($f, 'r');
  17. echo gzread($h, strlen($str1))."\n";
  18. var_dump(bin2hex(gzread($h, 20)));
  19. echo gzread($h, strlen($str2))."\n";
  20. gzclose($h);
  21. unlink($f);
  22. ?>
  23. --EXPECT--
  24. This is the first line.
  25. string(40) "0000000000000000000000000000000000000000"
  26. This is the second line.