1--TEST-- 2inflate_get_status() 3--EXTENSIONS-- 4zlib 5--FILE-- 6<?php 7 8$uncompressed = "Hello world."; 9$random_junk = str_repeat("qebsouesl", 128); 10 11$compressed = zlib_encode($uncompressed, ZLIB_ENCODING_DEFLATE); 12$compressed_len = strlen($compressed); 13$compressed .= $random_junk; 14 15$ctx = inflate_init(ZLIB_ENCODING_DEFLATE); 16$status = inflate_get_status($ctx); 17$buf = ''; 18 19for ($i = 0; $status == ZLIB_OK; ++$i) 20{ 21 $buf .= inflate_add($ctx, substr($compressed, $i, 1)); 22 echo '$i = ' . $i . ', '; 23 $status = inflate_get_status($ctx); 24 echo 'Status: ' . $status; 25 echo "\n"; 26} 27 28echo '$buf = ' . $buf; 29echo "\n\n"; 30 31echo "Adding more data should reset the stream and result in a Z_OK (ZLIB_OK) status.\n"; 32inflate_add($ctx, substr($compressed, 0, 12)); 33echo 'Status: ' . inflate_get_status($ctx); 34 35?> 36--EXPECT-- 37$i = 0, Status: 0 38$i = 1, Status: 0 39$i = 2, Status: 0 40$i = 3, Status: 0 41$i = 4, Status: 0 42$i = 5, Status: 0 43$i = 6, Status: 0 44$i = 7, Status: 0 45$i = 8, Status: 0 46$i = 9, Status: 0 47$i = 10, Status: 0 48$i = 11, Status: 0 49$i = 12, Status: 0 50$i = 13, Status: 0 51$i = 14, Status: 0 52$i = 15, Status: 0 53$i = 16, Status: 0 54$i = 17, Status: 0 55$i = 18, Status: 0 56$i = 19, Status: 1 57$buf = Hello world. 58 59Adding more data should reset the stream and result in a Z_OK (ZLIB_OK) status. 60Status: 0 61