php-doc-en/reference/zlib/reference.xml

133 lines
3.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.14 $ -->
<reference id="ref.zlib">
<title>Zlib Compression Functions</title>
<titleabbrev>Zlib</titleabbrev>
<partintro>
<section id="zlib.intro">
&reftitle.intro;
<para>
This module enables you to transparently read and write
gzip (.gz) compressed files, through versions of most of
the <link linkend="ref.filesystem">filesystem</link> functions
which work with gzip-compressed files (and uncompressed files,
too, but not with sockets).
</para>
<note>
<para>
Version 4.0.4 introduced a fopen-wrapper for .gz-files, so that
you can use a special 'zlib:' URL to access compressed files
transparently using the normal f*() file access functions if you
prepend the filename or path with a 'zlib:' prefix when calling
<function>fopen</function>.
</para>
<para>
In version 4.3.0, this special prefix has been changed to 'zlib://'
to prevent ambiguities with filenames containing ':'.
</para>
<para>
This feature requires a C runtime library that provides the
<literal>fopencookie()</literal> function. To my current
knowledge the GNU libc is the only library that provides
this feature.
</para>
</note>
</section>
<section id="zlib.requirements">
&reftitle.required;
<para>
This module uses the functions of <ulink url="&url.zlib;">zlib</ulink>
by Jean-loup Gailly and Mark Adler. You have to use a zlib
version &gt;= 1.0.9 with this module.
</para>
</section>
&reference.zlib.configure;
&reference.zlib.ini;
<section id="zlib.resources">
&reftitle.resources;
&no.resource;
</section>
&reference.zlib.constants;
<section id="zlib.examples">
&reftitle.examples;
<para>
This example opens a temporary file and writes a test string
to it, then it prints out the content of this file twice.
</para>
<example>
<title>Small Zlib Example</title>
<programlisting role="php">
<![CDATA[
<?php
$filename = tempnam('/tmp', 'zlibtest') . '.gz';
echo "<html>\n<head></head>\n<body>\n<pre>\n";
$s = "Only a test, test, test, test, test, test, test, test!\n";
// open file for writing with maximum compression
$zp = gzopen($filename, "w9");
// write string to file
gzwrite($zp, $s);
// close file
gzclose($zp);
// open file for reading
$zp = gzopen($filename, "r");
// read 3 char
echo gzread($zp, 3);
// output until end of the file and close it.
gzpassthru($zp);
gzclose($zp);
echo "\n";
// open file and print content (the 2nd time).
if (readgzfile($filename) != strlen($s)) {
echo "Error with zlib functions!";
}
unlink($filename);
echo "</pre>\n</body>\n</html>\n";
?>
]]>
</programlisting>
</example>
</section>
</partintro>
&reference.zlib.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->