<HTML ><HEAD ><TITLE >Bzip2 Compression Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="bcsub" HREF="function.bcsub.html"><LINK REL="NEXT" TITLE="bzclose" HREF="function.bzclose.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.bcsub.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.bzclose.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.bzip2" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >V. Bzip2 Compression Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN9795" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.intro" ></A >Introduction</H1 ><P > The bzip2 functions are used to transparently read and write bzip2 (.bz2) compressed files. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.requirements" ></A >Requirements</H1 ><P > This module uses the functions of the <A HREF="http://sources.redhat.com/bzip2/" TARGET="_top" >bzip2 </A > library by Julian Seward. This module requires bzip2/libbzip2 version >= 1.0.x. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.installation" ></A >Installation</H1 ><P > Bzip2 support in <TT CLASS="literal" >PHP</TT > is not enabled by default. You will need to use the <TT CLASS="option" >--with-bz2[=DIR]</TT > configuration option when compiling PHP to enable bzip2 support. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.resources" ></A >Resource Types</H1 ><P > This extension defines one resource type: a file pointer identifying the bz2-file to work on. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="bzip2.examples" ></A >Examples</H1 ><P > This example opens a temporary file and writes a test string to it, then prints out the contents of the file. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN9821" ></A ><P ><B >Example 1. Small bzip2 Example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $filename = "/tmp/testfile.bz2"; $str = "This is a test string.\n"; // open file for writing $bz = bzopen($filename, "w"); // write string to file bzwrite($bz, $str); // close file bzclose($bz); // open file for reading $bz = bzopen($filename, "r"); // read 10 characters print bzread($bz, 10); // output until end of the file (or the next 1024 char) and close it. print bzread($bz); bzclose($bz); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.bzclose.html" >bzclose</A > -- Close a bzip2 file pointer</DT ><DT ><A HREF="function.bzcompress.html" >bzcompress</A > -- Compress a string into bzip2 encoded data</DT ><DT ><A HREF="function.bzdecompress.html" >bzdecompress</A > -- Decompresses bzip2 encoded data</DT ><DT ><A HREF="function.bzerrno.html" >bzerrno</A > -- Returns a bzip2 error number</DT ><DT ><A HREF="function.bzerror.html" >bzerror</A > -- Returns the bzip2 error number and error string in an array</DT ><DT ><A HREF="function.bzerrstr.html" >bzerrstr</A > -- Returns a bzip2 error string</DT ><DT ><A HREF="function.bzflush.html" >bzflush</A > -- Force a write of all buffered data</DT ><DT ><A HREF="function.bzopen.html" >bzopen</A > -- Open a bzip2 compressed file</DT ><DT ><A HREF="function.bzread.html" >bzread</A > -- Binary safe bzip2 file read</DT ><DT ><A HREF="function.bzwrite.html" >bzwrite</A > -- Binary safe bzip2 file write</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.bcsub.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.bzclose.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >bcsub</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >bzclose</TD ></TR ></TABLE ></DIV ></BODY ></HTML >