gzopen_basic2.phpt 906 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test gzopen() function : basic functionality for writing
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. echo "*** Testing gzopen() : basic functionality ***\n";
  8. // Initialise all required variables
  9. $filename = "gzopen_basic2.txt.gz";
  10. $modes = array('w', 'w+');
  11. $data = "This was the information that was written";
  12. foreach($modes as $mode) {
  13. echo "testing mode -- $mode --\n";
  14. $h = gzopen($filename, $mode);
  15. if ($h !== false) {
  16. gzwrite($h, $data);
  17. gzclose($h);
  18. $h = gzopen($filename, 'r');
  19. gzpassthru($h);
  20. gzclose($h);
  21. echo "\n";
  22. unlink($filename);
  23. }
  24. else {
  25. var_dump($h);
  26. }
  27. }
  28. ?>
  29. --EXPECTF--
  30. *** Testing gzopen() : basic functionality ***
  31. testing mode -- w --
  32. This was the information that was written
  33. testing mode -- w+ --
  34. Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d
  35. bool(false)