Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 12300

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Zip File Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
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=UTF-8"></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 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.yp-order.html"
ACCESSKEY="P"
>上一页</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"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.zip"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>CLXXXVII. Zip File Functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN249402"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.intro"
>简介</A
></H1
><P
>&#13;    This extension enables you to transparently read or write ZIP compressed
    archives and the files inside them.
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.requirements"
>需求</A
></H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="zip.requirements.old"
>PHP 4</A
></H2
><P
>&#13;     The bundled PHP 4 version requires <A
HREF="http://zziplib.sourceforge.net/"
TARGET="_top"
>ZZIPlib</A
>,
     by Guido Draheim, version 0.10.6 or later 
    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="zip.requirements.new"
>PHP 5.2.0 or later</A
></H2
><P
>&#13;     This extension uses the functions of <A
HREF="http://www.gzip.org/zlib/"
TARGET="_top"
>zlib</A
>
     by Jean-loup Gailly and Mark Adler.
    </P
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.installation"
>安装</A
></H1
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="zip.old.installation"
>PHP 4</A
></H2
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
    Zip support before PHP 4.1.0 is experimental.
   </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
BORDER="1"
WIDTH="100%"
><TR
><TD
ALIGN="CENTER"
><B
>警告</B
></TD
></TR
><TR
><TD
ALIGN="LEFT"
><P
>&#13;    Because the PHP 4 zip extension is unmaintained we recommend that the PECL
    extension is used rather than the bundled one.
   </P
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="zip.installation.old.linux"
>Linux systems</A
></H3
><P
>&#13;    In order to use these functions you must compile PHP with zip support
    by using the <CODE
CLASS="option"
>--with-zip[=DIR]</CODE
>
    configure option, where [DIR] is the prefix of the <A
HREF="http://zziplib.sourceforge.net/"
TARGET="_top"
>ZZIPlib</A
> library install.
   </P
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="zip.installation.old.windows"
>Windows</A
></H3
><P
>&#13;    Windows users need to enable <TT
CLASS="filename"
>php_zip.dll</TT
> inside
    of <TT
CLASS="filename"
>php.ini</TT
> in order to use these functions.
   </P
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="zip.installation.new"
>PHP 5.2.0 and later</A
></H2
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="zip.installation.new.linux"
>Linux systems</A
></H3
><P
>&#13;    In order to use these functions you must compile PHP with zip support
    by using the <CODE
CLASS="option"
>--enable-zip</CODE
>
    configure option.
   </P
></DIV
><DIV
CLASS="section"
><H3
CLASS="section"
><A
NAME="zip.installation.new.windows"
>Windows</A
></H3
><P
>&#13;    Windows users need to enable <TT
CLASS="filename"
>php_zip.dll</TT
> inside
    of <TT
CLASS="filename"
>php.ini</TT
> in order to use these functions.
   </P
></DIV
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="zip.pecl.installation"
>Installation via PECL</A
></H2
><P
>&#13;   安装此 PECL 扩展库的信息可在手册中标题为 <A
HREF="install.pecl.html"
>PECL 扩展库安装</A
>的一章中找到。 更多信息如新版本,下载,源文件,维护者信息以及更新日志等可以在这里找到:
   <A
HREF="http://pecl.php.net/package/zip"
TARGET="_top"
>http://pecl.php.net/package/zip</A
>.
  </P
><P
>&#13;   可以从 <A
HREF="http://www.php.net/downloads.php"
TARGET="_top"
>PHP
下载页面</A
>或者 <A
HREF="http://snaps.php.net/"
TARGET="_top"
>http://snaps.php.net/</A
>
下载此 <ACRONYM
CLASS="acronym"
>PECL</ACRONYM
> 扩展的
<ACRONYM
CLASS="acronym"
>DLL</ACRONYM
> 文件。
  </P
><P
>&#13;   在 PHP 4 中本 <ACRONYM
CLASS="acronym"
>DLL</ACRONYM
> 位于
PHP Windows 执行包中的 <TT
CLASS="filename"
>extensions/</TT
> 目录下。
  </P
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.configuration"
>运行时配置</A
></H1
><P
>本扩展模块在 <TT
CLASS="filename"
>php.ini</TT
> 中未定义任何配置选项。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.resources"
>资源类型</A
></H1
><P
>&#13;    There are two resource types used in the Zip module. The first one
    is the Zip directory for the Zip archive, the second Zip Entry for
    the archive entries.
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.constants"
>预定义常量</A
></H1
><P
>以下常量由本扩展模块定义,因此只有在本扩展模块被编译到
PHP 中,或者在运行时被动态加载后才有效。</P
><P
>&#13;   ZipArchive uses class constants. There is three types of constants,
   Flags (FL_) errors (ER_) or mode (no prefix).
  </P
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CREATE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Create the archive if it does not exist.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::OVERWRITE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Always start a new archive, this mode will overwrite the file if
     it already exists.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::EXCL</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Error if archive already exists.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CHECKCONS</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Perform additional consistency checks on the archive, and error if they fail.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::FL_NOCASE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Ignore case on name lookup
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::FL_NODIR</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Ignore directory component
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::FL_COMPRESSED</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Read compressed data
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::FL_UNCHANGED</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Use original data, ignoring changes.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_DEFAULT</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     better of deflate or store.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_STORE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     stored (uncompressed).
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_SHRINK</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     shrunk
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_REDUCE_1</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     reduced with factor 1
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_REDUCE_2</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     reduced with factor 2
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_REDUCE_3</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     reduced with factor 3
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_REDUCE_4</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     reduced with factor 4
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_IMPLODE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     imploded
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_DEFLATE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     deflated
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_DEFLATE64</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     deflate64
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_PKWARE_IMPLODE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     PKWARE imploding
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::CM_BZIP2</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     BZIP2 algorithm
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_OK</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     No error.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_MULTIDISK</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Multi-disk zip archives not supported.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_RENAME</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Renaming temporary file failed.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_CLOSE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Closing zip archive failed
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_SEEK</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;      Seek error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_READ</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Read error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_WRITE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Write error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_CRC</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     CRC error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_ZIPCLOSED</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Containing zip archive was closed
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_NOENT</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     No such file.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_EXISTS</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     File already exists
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_OPEN</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Can't open file
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_TMPOPEN</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Failure to create temporary file.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_ZLIB</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Zlib error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_MEMORY</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Memory allocation failure
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_CHANGED</B
></TT
>
     (<A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>)</DT
><DD
><P
>&#13;     Entry has been changed
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_COMPNOTSUPP</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Compression method not supported.
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_EOF</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Premature EOF
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_INVAL</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Invalid argument
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_NOZIP</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Not a zip archive
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_INTERNAL</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Internal error
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_INCONS</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Zip archive inconsistent
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_REMOVE</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Can't remove file
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>ZIPARCHIVE::ER_DELETED</B
></TT
>
     (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     Entry has been deleted
    </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zip.examples"
>范例</A
></H1
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN249736"
></A
><P
><B
>例 1. Create a Zip archive</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$zip </font><font color="#007700">= new </font><font color="#0000BB">ZipArchive</font><font color="#007700">();<br /></font><font color="#0000BB">$filename </font><font color="#007700">= </font><font color="#DD0000">"./test112.zip"</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">open</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">, </font><font color="#0000BB">ZIPARCHIVE</font><font color="#007700">::</font><font color="#0000BB">CREATE</font><font color="#007700">)!==</font><font color="#0000BB">TRUE</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;exit(</font><font color="#DD0000">"cannot open &lt;$filename&gt;</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">);<br />}<br /><br /></font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">addFromString</font><font color="#007700">(</font><font color="#DD0000">"testfilephp.txt" </font><font color="#007700">. </font><font color="#0000BB">time</font><font color="#007700">(), </font><font color="#DD0000">"#1 This is a test string added as testfilephp.txt.\n"</font><font color="#007700">);<br /></font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">addFromString</font><font color="#007700">(</font><font color="#DD0000">"testfilephp2.txt" </font><font color="#007700">. </font><font color="#0000BB">time</font><font color="#007700">(), </font><font color="#DD0000">"#2 This is a test string added as testfilephp2.txt.\n"</font><font color="#007700">);<br /></font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">addFile</font><font color="#007700">(</font><font color="#0000BB">$thisdir </font><font color="#007700">. </font><font color="#DD0000">"/too.php"</font><font color="#007700">,</font><font color="#DD0000">"/testfromfile.php"</font><font color="#007700">);<br />echo </font><font color="#DD0000">"numfiles: " </font><font color="#007700">. </font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">numFiles </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">"status:" </font><font color="#007700">. </font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">status </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /></font><font color="#0000BB">$zip</font><font color="#007700">-&gt;</font><font color="#0000BB">close</font><font color="#007700">();<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN249739"
></A
><P
><B
>例 2. Dump the archive details and listing</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$za </font><font color="#007700">= new </font><font color="#0000BB">ZipArchive</font><font color="#007700">();<br /><br /></font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">open</font><font color="#007700">(</font><font color="#DD0000">'test_with_comment.zip'</font><font color="#007700">);<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$za</font><font color="#007700">);<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$za</font><font color="#007700">);<br />echo </font><font color="#DD0000">"numFiles: " </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">numFiles </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">"status: " </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">status&nbsp;&nbsp;</font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">"statusSys: " </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">statusSys </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">"filename: " </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">filename </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />echo </font><font color="#DD0000">"comment: " </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">comment </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br />for (</font><font color="#0000BB">$i</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$i</font><font color="#007700">&lt;</font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">numFiles</font><font color="#007700">;</font><font color="#0000BB">$i</font><font color="#007700">++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"index: $i</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">statIndex</font><font color="#007700">(</font><font color="#0000BB">$i</font><font color="#007700">));<br />}<br />echo </font><font color="#DD0000">"numFile:" </font><font color="#007700">. </font><font color="#0000BB">$za</font><font color="#007700">-&gt;</font><font color="#0000BB">numFiles </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN249742"
></A
><P
><B
>例 3. Zip stream wrapper, read an OpenOffice meta info</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$reader </font><font color="#007700">= new </font><font color="#0000BB">XMLReader</font><font color="#007700">();<br /><br /></font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">open</font><font color="#007700">(</font><font color="#DD0000">'zip://' </font><font color="#007700">. </font><font color="#0000BB">dirname</font><font color="#007700">(</font><font color="#0000BB">__FILE__</font><font color="#007700">) . </font><font color="#DD0000">'/test.odt#meta.xml'</font><font color="#007700">);<br /></font><font color="#0000BB">$odt_meta </font><font color="#007700">= array();<br />while (</font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">read</font><font color="#007700">()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">nodeType </font><font color="#007700">== </font><font color="#0000BB">XMLREADER</font><font color="#007700">::</font><font color="#0000BB">ELEMENT</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$elm </font><font color="#007700">= </font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">name</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">nodeType </font><font color="#007700">== </font><font color="#0000BB">XMLREADER</font><font color="#007700">::</font><font color="#0000BB">END_ELEMENT </font><font color="#007700">&amp;&amp; </font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">name </font><font color="#007700">== </font><font color="#DD0000">'office:meta'</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!</font><font color="#0000BB">trim</font><font color="#007700">(</font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">value</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$odt_meta</font><font color="#007700">[</font><font color="#0000BB">$elm</font><font color="#007700">] = </font><font color="#0000BB">$reader</font><font color="#007700">-&gt;</font><font color="#0000BB">value</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$odt_meta</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;    This example uses the old API (PHP 4), it 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="AEN249747"
></A
><P
><B
>例 4. Zip Usage Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$zip </font><font color="#007700">= </font><font color="#0000BB">zip_open</font><font color="#007700">(</font><font color="#DD0000">"/tmp/test2.zip"</font><font color="#007700">);<br /><br />if (</font><font color="#0000BB">$zip</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;while (</font><font color="#0000BB">$zip_entry </font><font color="#007700">= </font><font color="#0000BB">zip_read</font><font color="#007700">(</font><font color="#0000BB">$zip</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" </font><font color="#007700">. </font><font color="#0000BB">zip_entry_name</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Actual Filesize:&nbsp;&nbsp;&nbsp;&nbsp;" </font><font color="#007700">. </font><font color="#0000BB">zip_entry_filesize</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Compressed Size:&nbsp;&nbsp;&nbsp;&nbsp;" </font><font color="#007700">. </font><font color="#0000BB">zip_entry_compressedsize</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Compression Method: " </font><font color="#007700">. </font><font color="#0000BB">zip_entry_compressionmethod</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">zip_entry_open</font><font color="#007700">(</font><font color="#0000BB">$zip</font><font color="#007700">, </font><font color="#0000BB">$zip_entry</font><font color="#007700">, </font><font color="#DD0000">"r"</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"File Contents:\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$buf </font><font color="#007700">= </font><font color="#0000BB">zip_entry_read</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">, </font><font color="#0000BB">zip_entry_filesize</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"$buf</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">zip_entry_close</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">zip_close</font><font color="#007700">(</font><font color="#0000BB">$zip</font><font color="#007700">);<br /><br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.zip-close.html"
>zip_close</A
>&nbsp;--&nbsp;Close a ZIP file archive</DT
><DT
><A
HREF="function.zip-entry-close.html"
>zip_entry_close</A
>&nbsp;--&nbsp;Close a directory entry</DT
><DT
><A
HREF="function.zip-entry-compressedsize.html"
>zip_entry_compressedsize</A
>&nbsp;--&nbsp;Retrieve the compressed size of a directory entry</DT
><DT
><A
HREF="function.zip-entry-compressionmethod.html"
>zip_entry_compressionmethod</A
>&nbsp;--&nbsp;Retrieve the compression method of a directory entry</DT
><DT
><A
HREF="function.zip-entry-filesize.html"
>zip_entry_filesize</A
>&nbsp;--&nbsp;Retrieve the actual file size of a directory entry</DT
><DT
><A
HREF="function.zip-entry-name.html"
>zip_entry_name</A
>&nbsp;--&nbsp;Retrieve the name of a directory entry</DT
><DT
><A
HREF="function.zip-entry-open.html"
>zip_entry_open</A
>&nbsp;--&nbsp;Open a directory entry for reading</DT
><DT
><A
HREF="function.zip-entry-read.html"
>zip_entry_read</A
>&nbsp;--&nbsp;Read from an open directory entry</DT
><DT
><A
HREF="function.zip-open.html"
>zip_open</A
>&nbsp;--&nbsp;Open a ZIP file archive</DT
><DT
><A
HREF="function.zip-read.html"
>zip_read</A
>&nbsp;--&nbsp;Read next entry in a ZIP file archive</DT
><DT
><A
HREF="function.ziparchive-addfile.html"
>ZipArchive::addFile</A
>&nbsp;--&nbsp;Adds a file to a ZIP archive from the given path</DT
><DT
><A
HREF="function.ziparchive-addfromstring.html"
>ZipArchive::addFromString</A
>&nbsp;--&nbsp;Add a file to a ZIP archive using its contents</DT
><DT
><A
HREF="function.ziparchive-close.html"
>ZipArchive::close</A
>&nbsp;--&nbsp;Close the active archive (opened or newly created)</DT
><DT
><A
HREF="function.ziparchive-deleteindex.html"
>ZipArchive::deleteIndex</A
>&nbsp;--&nbsp;delete an entry in the archive using its index</DT
><DT
><A
HREF="function.ziparchive-deletename.html"
>ZipArchive::deleteName</A
>&nbsp;--&nbsp;delete an entry in the archive using its name</DT
><DT
><A
HREF="function.ziparchive-extractto.html"
>ZipArchive::extractTo</A
>&nbsp;--&nbsp;Extract the archive contents</DT
><DT
><A
HREF="function.ziparchive-getarchivecomment.html"
>ZipArchive::getArchiveComment</A
>&nbsp;--&nbsp;Returns the Zip archive comment</DT
><DT
><A
HREF="function.ziparchive-getcommentindex.html"
>ZipArchive::getCommentIndex</A
>&nbsp;--&nbsp;Returns the comment of an entry using the entry index</DT
><DT
><A
HREF="function.ziparchive-getcommentname.html"
>ZipArchive::getCommentName</A
>&nbsp;--&nbsp;Returns the comment of an entry using the entry name</DT
><DT
><A
HREF="function.ziparchive-getfromindex.html"
>ZipArchive::getFromIndex</A
>&nbsp;--&nbsp;Returns the entry contents using its index.</DT
><DT
><A
HREF="function.ziparchive-getfromname.html"
>ZipArchive::getFromName</A
>&nbsp;--&nbsp;Returns the entry contents using its name.</DT
><DT
><A
HREF="function.ziparchive-getnameindex.html"
>ZipArchive::getNameIndex</A
>&nbsp;--&nbsp;Returns the name of an entry using its index</DT
><DT
><A
HREF="function.ziparchive-getstream.html"
>ZipArchive::getStream</A
>&nbsp;--&nbsp;Get a file handler to the entry defined by its name (read only).</DT
><DT
><A
HREF="function.ziparchive-locatename.html"
>ZipArchive::locateName</A
>&nbsp;--&nbsp;Returns the index of the entry in the archive</DT
><DT
><A
HREF="function.ziparchive-open.html"
>ZipArchive::open</A
>&nbsp;--&nbsp;Open a ZIP file archive</DT
><DT
><A
HREF="function.ziparchive-renameindex.html"
>ZipArchive::renameIndex</A
>&nbsp;--&nbsp;Renames an entry defined by its index</DT
><DT
><A
HREF="function.ziparchive-renamename.html"
>ZipArchive::renameName</A
>&nbsp;--&nbsp;Renames an entry defined by its name</DT
><DT
><A
HREF="function.ziparchive-setarchivecomment.html"
>ZipArchive::setArchiveComment</A
>&nbsp;--&nbsp;Set the comment of a ZIP archive</DT
><DT
><A
HREF="function.ziparchive-setcommentindex.html"
>ZipArchive::setCommentIndex</A
>&nbsp;--&nbsp;Set the comment of an entry defined by its index</DT
><DT
><A
HREF="function.ziparchive-setcommentname.html"
>ZipArchive::setCommentName</A
>&nbsp;--&nbsp;Set the comment of an entry defined by its name</DT
><DT
><A
HREF="function.ziparchive-statindex.html"
>ZipArchive::statIndex</A
>&nbsp;--&nbsp;Get the details of an entry defined by its index.</DT
><DT
><A
HREF="function.ziparchive-statname.html"
>ZipArchive::statName</A
>&nbsp;--&nbsp;Get the details of an entry defined by its name.</DT
><DT
><A
HREF="function.ziparchive-unchangeall.html"
>ZipArchive::unchangeAll</A
>&nbsp;--&nbsp;Undo all changes done in the archive.</DT
><DT
><A
HREF="function.ziparchive-unchangearchive.html"
>ZipArchive::unchangeArchive</A
>&nbsp;--&nbsp;Revert all global changes done in the archive.</DT
><DT
><A
HREF="function.ziparchive-unchangeindex.html"
>ZipArchive::unchangeIndex</A
>&nbsp;--&nbsp;Revert all changes done to an entry at the given index.</DT
><DT
><A
HREF="function.ziparchive-unchangename.html"
>ZipArchive::unchangeName</A
>&nbsp;--&nbsp;Revert all changes done to an entry with the given name.</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"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.zip-close.html"
ACCESSKEY="N"
>下一页</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"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>zip_close</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>