gzseek_variation7.phpt 852 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test function gzseek() by calling it with SEEK_END when writing
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. $f = "gzseek_variation7.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=";
  13. var_dump(gztell($h));
  14. //seek to the end which is not sensible of course.
  15. echo "move to the end of the file\n";
  16. var_dump(gzseek($h, 0, SEEK_END));
  17. echo "tell=";
  18. var_dump(gztell($h));
  19. gzwrite($h, $str2);
  20. echo "tell=";
  21. var_dump(gztell($h));
  22. gzclose($h);
  23. echo "\nreading the output file\n";
  24. $h = gzopen($f, 'r');
  25. gzpassthru($h);
  26. gzclose($h);
  27. echo "\n";
  28. unlink($f);
  29. ?>
  30. --EXPECTF--
  31. tell=int(23)
  32. move to the end of the file
  33. Warning: gzseek(): SEEK_END is not supported in %s on line %d
  34. int(-1)
  35. tell=int(23)
  36. tell=int(47)
  37. reading the output file
  38. This is the first line.This is the second line.