php-src/ext/zlib/tests/gzreadgzwrite.phpt
Michael Wallner 11d24c1593 * implement new output API, fixing some bugs and implementing some feature
requests--let's see what I can dig out of the bugtracker for NEWS--
  and while crossing the road:
   * implemented new zlib API
   * fixed up ext/tidy (what was "s&" in zend_parse_parameters() supposed to do?)

Thanks to Jani and Felipe for pioneering.
2010-05-31 10:29:43 +00:00

37 lines
642 B
PHP

--TEST--
gzopen(), gzread(), gzwrite()
--SKIPIF--
<?php # vim600:syn=php:
if (!extension_loaded("zlib")) print "skip"; ?>
--FILE--
<?php
$original = str_repeat(b"hallo php",4096);
$filename = tempnam("/tmp", "phpt");
$fp = gzopen($filename, "wb");
gzwrite($fp, $original);
var_dump(strlen($original));
var_dump(gztell($fp));
fclose($fp);
$fp = gzopen($filename, "rb");
$data = '';
while ($buf = gzread($fp, 8092)) {
$data .= $buf;
}
if ($data == $original) {
echo "Strings are equal\n";
} else {
echo "Strings are not equal\n";
var_dump($data);
}
gzclose($fp);
unlink($filename);
?>
--EXPECT--
int(36864)
int(36864)
Strings are equal