<HTML ><HEAD ><TITLE >Zip File Functions (Read Only Access)</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="yp_order" HREF="function.yp-order.html"><LINK REL="NEXT" TITLE="zip_close" HREF="function.zip-close.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.yp-order.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.zip-close.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.zip" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CXII. Zip File Functions (Read Only Access)</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN98555" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.intro" ></A >Introduction</H1 ><P > This module enables you to transparently read ZIP compressed archives and the files inside them. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.requirements" ></A >Requirements</H1 ><P > This module uses the functions of the <A HREF="http://zziplib.sourceforge.net/" TARGET="_top" >ZZIPlib</A > library by Guido Draheim. You need ZZIPlib version >= 0.10.6. </P ><P > Note that ZZIPlib only provides a subset of functions provided in a full implementation of the ZIP compression algorithm and can only read ZIP file archives. A normal ZIP utility is needed to create the ZIP file archives read by this library. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.installation" ></A >Installation</H1 ><P > Zip support in PHP is not enabled by default. You will need to use the <TT CLASS="option" >--with-zip[=DIR]</TT > configuration option when compiling PHP to enable zip support. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > Zip support before PHP 4.1.0 is experimental. This section reflects the Zip extension as it exists in PHP 4.1.0 and later. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.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="zip.resources" ></A >Resource Types</H1 ><P >This extension has no resource types defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.examples" ></A >Examples</H1 ><P > This example opens a ZIP file archive, reads each file in the archive and prints out its contents. The <TT CLASS="filename" >test2.zip</TT > archive used in this example is one of the test archives in the ZZIPlib source distribution. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN98584" ></A ><P ><B >Example 1. Zip Usage Example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $zip = zip_open("/tmp/test2.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { echo "Name: " . zip_entry_name($zip_entry) . "\n"; echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "\n"; echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "\n"; echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "\n"; if (zip_entry_open($zip, $zip_entry, "r")) { echo "File Contents:\n"; $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); echo "$buf\n"; zip_entry_close($zip_entry); } echo "\n"; } zip_close($zip); } ?></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.zip-close.html" >zip_close</A > -- Close a Zip File Archive</DT ><DT ><A HREF="function.zip-entry-close.html" >zip_entry_close</A > -- Close a Directory Entry</DT ><DT ><A HREF="function.zip-entry-compressedsize.html" >zip_entry_compressedsize</A > -- Retrieve the Compressed Size of a Directory Entry</DT ><DT ><A HREF="function.zip-entry-compressionmethod.html" >zip_entry_compressionmethod</A > -- Retrieve the Compression Method of a Directory Entry</DT ><DT ><A HREF="function.zip-entry-filesize.html" >zip_entry_filesize</A > -- Retrieve the Actual File Size of a Directory Entry</DT ><DT ><A HREF="function.zip-entry-name.html" >zip_entry_name</A > -- Retrieve the Name of a Directory Entry</DT ><DT ><A HREF="function.zip-entry-open.html" >zip_entry_open</A > -- Open a Directory Entry for Reading</DT ><DT ><A HREF="function.zip-entry-read.html" >zip_entry_read</A > -- Read From an Open Directory Entry</DT ><DT ><A HREF="function.zip-open.html" >zip_open</A > -- Open a Zip File Archive</DT ><DT ><A HREF="function.zip-read.html" >zip_read</A > -- Read Next Entry in a Zip File Archive</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.yp-order.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.zip-close.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >yp_order</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >zip_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >