1--TEST-- 2Test compress.zlib:// scheme with the copy function: uncompressed to compressed 3--EXTENSIONS-- 4zlib 5--FILE-- 6<?php 7$org_data = <<<EOT 8uncompressed contents of 004.txt.gz is: 9When you're taught through feelings 10Destiny flying high above 11all I know is that you can realize it 12Destiny who cares 13as it turns around 14and I know that it descends down on me 15EOT; 16 17$inputFileName = __FILE__.'.org'; 18$outputFileName = __FILE__.'.tmp'; 19 20file_put_contents($inputFileName, $org_data); 21 22$srcFile = $inputFileName; 23$destFile = "compress.zlib://$outputFileName"; 24copy($srcFile, $destFile); 25 26$h = gzopen($outputFileName, 'r'); 27$copied_data = gzread($h, 4096); 28gzclose($h); 29 30//gzopen can read compressed and uncompressed so we 31//also need to look for the magic number (x1f x8b) to prove it 32//was compressed. 33$h = fopen($outputFileName, 'r'); 34$magic = fread($h, 2); 35fclose($h); 36 37if ($org_data == $copied_data && bin2hex($magic) === '1f8b') { 38 echo "OK: Copy identical\n"; 39} 40else { 41 echo "FAILED: Copy not identical\n"; 42} 43unlink($inputFileName); 44unlink($outputFileName); 45?> 46--EXPECT-- 47OK: Copy identical 48