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