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