gzseek_basic2.phpt 900 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test function gzseek() by calling it with its expected arguments when writing
  3. --SKIPIF--
  4. <?php
  5. if (!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.";
  15. gzwrite($h, $str1);
  16. echo "tell=".gztell($h)."\n";
  17. //seek forwards 20 bytes.
  18. gzseek($h, strlen($str1) + 20);
  19. echo "tell=".gztell($h)."\n";
  20. gzwrite($h, $str2);
  21. echo "tell=".gztell($h)."\n";
  22. gzclose($h);
  23. echo "\nreading the output file\n";
  24. $h = gzopen($f, 'r');
  25. echo gzread($h, strlen($str1))."\n";
  26. var_dump(bin2hex(gzread($h, 20)));
  27. echo gzread($h, strlen($str2))."\n";
  28. gzclose($h);
  29. unlink($f);
  30. ?>
  31. ===DONE===
  32. --EXPECT--
  33. tell=23
  34. tell=43
  35. tell=67
  36. reading the output file
  37. This is the first line.
  38. string(40) "0000000000000000000000000000000000000000"
  39. This is the second line.
  40. ===DONE===