1--TEST-- 2gzopen(), gzread(), gzwrite() for non-compressed data 3--SKIPIF-- 4<?php # vim600:syn=php: 5if (!extension_loaded("zlib")) print "skip"; ?> 6--FILE-- 7<?php 8$original = str_repeat("hallo php",4096); 9$filename = tempnam(sys_get_temp_dir(), "phpt"); 10 11$fp = fopen($filename, "wb"); 12fwrite($fp, $original); 13var_dump(strlen($original)); 14var_dump(ftell($fp)); 15fclose($fp); 16 17$fp = gzopen($filename, "rb"); 18 19$data = ''; 20while ($buf = gzread($fp, 8192)) { 21 $data .= $buf; 22} 23 24if ($data == $original) { 25 echo "Strings are equal\n"; 26} else { 27 echo "Strings are not equal\n"; 28 var_dump($data); 29} 30 31gzseek($fp, strlen($original) / 2); 32 33$data = ''; 34while ($buf = gzread($fp, 8192)) { 35 $data .= $buf; 36} 37 38var_dump(strlen($data)); 39if ($data == substr($original, strlen($original) / 2)) { 40 echo "Strings are equal\n"; 41} else { 42 echo "Strings are not equal\n"; 43 var_dump($data); 44} 45 46gzclose($fp); 47unlink($filename); 48?> 49--EXPECT-- 50int(36864) 51int(36864) 52Strings are equal 53int(18432) 54Strings are equal 55