reference/zlib/examples.xml
eec6a4a36bf452bf271f116e7b6b9bb09d1181c3
...
...
@@ -49,6 +49,32 @@ echo "</pre>\n</body>\n</html>\n";
49
49
]]>
50
50
</programlisting>
51
51
</example>
52
+
<example>
53
+
<title>Working with the incremental compression and decompression API</title>
54
+
<programlisting role="php">
55
+
<![CDATA[
56
+
<?php
57
+
// Perform GZIP compression:
58
+
$deflateContext = deflate_init(ZLIB_ENCODING_GZIP);
59
+
$compressed = deflate_add($deflateContext, "Data to compress", ZLIB_NO_FLUSH);
60
+
$compressed .= deflate_add($deflateContext, ", more data", ZLIB_NO_FLUSH);
61
+
$compressed .= deflate_add($deflateContext, ", and even more data!", ZLIB_FINISH);
62
+

63
+
// Perform GZIP decompression:
64
+
$inflateContext = inflate_init(ZLIB_ENCODING_GZIP);
65
+
$uncompressed = inflate_add($inflateContext, $compressed, ZLIB_NO_FLUSH);
66
+
$uncompressed .= inflate_add($inflateContext, NULL, ZLIB_FINISH);
67
+
echo $uncompressed;
68
+
?>
69
+
]]>
70
+
</programlisting>
71
+
&example.outputs;
72
+
<screen>
73
+
<![CDATA[
74
+
Data to compress, more data, and even more data!
75
+
]]>
76
+
</screen>
77
+
</example>
52
78
</chapter>
53
79

54
80
<!-- Keep this comment at the end of the file
55
81