php-doc-en/reference/zlib/reference.xml
Hartmut Holzgraefe a4b6d72ad3 banana-split
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78202 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-15 00:12:54 +00:00

132 lines
2.9 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<reference id="ref.zlib">
<title>Zlib Compression Functions</title>
<titleabbrev>Zlib</titleabbrev>
<partintro>
<para>
This module uses the functions of <ulink
url="&url.zlib;">zlib</ulink> by Jean-loup Gailly and Mark Adler to
transparently read and write gzip (.gz) compressed files. You have
to use a zlib version >= 1.0.9 with this module.
</para>
<para>
This module contains 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 introduces 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 id="zlib-example">
<title>Small code example</title>
<para>
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';
print "<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
print gzread($zp, 3);
// output until end of the file and close it.
gzpassthru($zp);
print "\n";
// open file and print content (the 2nd time).
if (readgzfile($filename) != strlen($s)) {
echo "Error with zlib functions!";
}
unlink($filename);
print "</pre>\n</h1></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
-->