<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Zip File Functions (Read Only Access)</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.yp-order.html" ACCESSKEY="P" >Anterior</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" >Próxima</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 (Read Only Access)</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN242618" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.intro" >Introdução</A ></H1 ><P > Este módulo lhe permite ler arquivos ZIPados e os seus conteúdos </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.requirements" >Dependências</A ></H1 ><P > Este módulo usa as funções da biblioteca <A HREF="http://zziplib.sourceforge.net/" TARGET="_top" >ZZIPlib</A > escrita por Guido Draheim. Você precisará da biblioteca ZZIPlib na versão >= 0.10.6. </P ><P > Observe que a ZZIPlib provem apenas uma biblioteca de funções para ler arquivos ZIPados. Para criar arquivos no formato ZIP será necessário um programa como o WINZIP. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.installation" >Instalação</A ></H1 ><P > Esta estensão <A HREF="http://pecl.php.net" TARGET="_top" >PECL</A > não vem compilada com o PHP. Informações para a instalação desta extensão PECL podem ser encontradas no manual no capitulo entitulado <A HREF="install.pecl.html" >Instalação de extensões PECL</A >. Informações adicionais como novas versões, downloads, arquivos fontes, manutenções, e um Changelog, podem ser obtidos aqui: <A HREF="http://pecl.php.net/package/zip" TARGET="_top" >http://pecl.php.net/package/zip</A >. </P ><P > No PHP 4, os fontes desta estensão <ACRONYM CLASS="acronym" >PECL</ACRONYM > podem ser encontrados no diretório <TT CLASS="filename" >ext/</TT > ou dentro dos fontes do PHP ou no link <ACRONYM CLASS="acronym" >PECL</ACRONYM > acima. Para usar as funções de manipulação de arquivo ZIP você deve compilar o PHP com suporte aos arquivos ZIP usando este comando <CODE CLASS="option" >--with-zip[=DIR]</CODE > </P ><P > Usuários windows precisam abilitar a seguinte dll <TT CLASS="filename" >php_zip.dll</TT > dentro do diretório em que está o arquivo <TT CLASS="filename" >php.ini</TT > para abilitar as funções de manipulação de arquivos ZIP. No PHP esta <ACRONYM CLASS="acronym" >DLL</ACRONYM > reside no diretório <TT CLASS="filename" >extensions/</TT > junto aos binários do PHP para Windows. Você pode baixar esta extensão <ACRONYM CLASS="acronym" >PECL</ACRONYM > <ACRONYM CLASS="acronym" >DLL</ACRONYM > a apartir de <A HREF="http://www.php.net/downloads.php" TARGET="_top" > downloads PHP</A > ou em <A HREF="http://snaps.php.net/" TARGET="_top" > http://snaps.php.net/</A >. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > O suporte as funções ZIP antes da versão 4.1.0 é experimental. Após a versão 4.1.0 ele deixa de ser expimental e passa a incrementar as funções do PHP. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.resources" >Tipos Resource</A ></H1 ><P >Esta extensão não possui nenhum tipo resource.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.constants" >Constantes pré-definidas</A ></H1 ><P >Esta extensão não possui nenhuma constante.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zip.examples" >Exemplos</A ></H1 ><P > Este exemplo abri um arquivo zipado, lê cada arquivo que está dentro do arquivo ZIPado e mostra o conteúdo de cada um. O <TT CLASS="filename" >test2.zip</TT > é um arquivo usado neste exemplo e faz parte do arquivos contidos no pacote de distribuição da ZZIPlib. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN242663" ></A ><P ><B >Exemplo 1. Exemplo</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?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 /><br /> 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 /> echo </font><font color="#DD0000">"Name: " </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 /> echo </font><font color="#DD0000">"Actual Filesize: " </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 /> echo </font><font color="#DD0000">"Compressed Size: " </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 /> 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 /> 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 /> echo </font><font color="#DD0000">"File Contents:\n"</font><font color="#007700">;<br /> </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 /> echo </font><font color="#DD0000">"$buf</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br /><br /> </font><font color="#0000BB">zip_entry_close</font><font color="#007700">(</font><font color="#0000BB">$zip_entry</font><font color="#007700">);<br /> }<br /> echo </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /> }<br /><br /> </font><font color="#0000BB">zip_close</font><font color="#007700">(</font><font color="#0000BB">$zip</font><font color="#007700">);<br /><br />}<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.zip-close.html" >zip_close</A > -- Fecha um arquivo ZIP</DT ><DT ><A HREF="function.zip-entry-close.html" >zip_entry_close</A > -- Fecha o arquivo que está aberto</DT ><DT ><A HREF="function.zip-entry-compressedsize.html" >zip_entry_compressedsize</A > -- Recupera o tamanho compactado do arquivo que está dentro do arquivo ZIP</DT ><DT ><A HREF="function.zip-entry-compressionmethod.html" >zip_entry_compressionmethod</A > -- Recupera qual o método de compressão foi utilizado no arquivo</DT ><DT ><A HREF="function.zip-entry-filesize.html" >zip_entry_filesize</A > -- Retorna o tamanho do arquivo</DT ><DT ><A HREF="function.zip-entry-name.html" >zip_entry_name</A > -- Retorna o nome do arquivo</DT ><DT ><A HREF="function.zip-entry-open.html" >zip_entry_open</A > -- Abre um arquivo do arquivo ZIP</DT ><DT ><A HREF="function.zip-entry-read.html" >zip_entry_read</A > -- Le de um arquivo aberto</DT ><DT ><A HREF="function.zip-open.html" >zip_open</A > -- Abre um arquivo ZIPado</DT ><DT ><A HREF="function.zip-read.html" >zip_read</A > -- Lê o próximo elemento ques está dentro de um arquivo ZIPado</DT ><DT ><A HREF="function.ziparchive-addfile.html" >ZipArchive::addFile</A > -- Adds a file to a ZIP archive from the given path</DT ><DT ><A HREF="function.ziparchive-addfromstring.html" >ZipArchive::addFromString</A > -- Add a file to a ZIP archive using its contents</DT ><DT ><A HREF="function.ziparchive-close.html" >ZipArchive::close</A > -- Close the active archive (opened or newly created)</DT ><DT ><A HREF="function.ziparchive-deleteindex.html" >ZipArchive::deleteIndex</A > -- delete an entry in the archive using its index</DT ><DT ><A HREF="function.ziparchive-deletename.html" >ZipArchive::deleteName</A > -- delete an entry in the archive using its name</DT ><DT ><A HREF="function.ziparchive-extractto.html" >ZipArchive::extractTo</A > -- Extract the archive contents</DT ><DT ><A HREF="function.ziparchive-getarchivecomment.html" >ZipArchive::getArchiveComment</A > -- Returns the Zip archive comment</DT ><DT ><A HREF="function.ziparchive-getcommentindex.html" >ZipArchive::getCommentIndex</A > -- Returns the comment of an entry using the entry index</DT ><DT ><A HREF="function.ziparchive-getcommentname.html" >ZipArchive::getCommentName</A > -- Returns the comment of an entry using the entry name</DT ><DT ><A HREF="function.ziparchive-getfromindex.html" >ZipArchive::getFromIndex</A > -- Returns the entry contents using its index.</DT ><DT ><A HREF="function.ziparchive-getfromname.html" >ZipArchive::getFromName</A > -- Returns the entry contents using its name.</DT ><DT ><A HREF="function.ziparchive-getnameindex.html" >ZipArchive::getNameIndex</A > -- Returns the name of an entry using its index</DT ><DT ><A HREF="function.ziparchive-getstream.html" >ZipArchive::getStream</A > -- Get a file handler to the entry defined by its name (read only).</DT ><DT ><A HREF="function.ziparchive-locatename.html" >ZipArchive::locateName</A > -- Returns the index of the entry in the archive</DT ><DT ><A HREF="function.ziparchive-open.html" >ZipArchive::open</A > -- Open a ZIP file archive</DT ><DT ><A HREF="function.ziparchive-renameindex.html" >ZipArchive::renameIndex</A > -- Renames an entry defined by its index</DT ><DT ><A HREF="function.ziparchive-renamename.html" >ZipArchive::renameName</A > -- Renames an entry defined by its name</DT ><DT ><A HREF="function.ziparchive-setarchivecomment.html" >ZipArchive::setArchiveComment</A > -- Set the comment of a ZIP archive</DT ><DT ><A HREF="function.ziparchive-setcommentindex.html" >ZipArchive::setCommentIndex</A > -- Set the comment of an entry defined by its index</DT ><DT ><A HREF="function.ziparchive-setcommentname.html" >ZipArchive::setCommentName</A > -- Set the comment of an entry defined by its name</DT ><DT ><A HREF="function.ziparchive-statindex.html" >ZipArchive::statIndex</A > -- Get the details of an entry defined by its index.</DT ><DT ><A HREF="function.ziparchive-statname.html" >ZipArchive::statName</A > -- Get the details of an entry defined by its name.</DT ><DT ><A HREF="function.ziparchive-unchangeall.html" >ZipArchive::unchangeAll</A > -- Undo all changes done in the archive.</DT ><DT ><A HREF="function.ziparchive-unchangearchive.html" >ZipArchive::unchangeArchive</A > -- Revert all global changes done in the archive.</DT ><DT ><A HREF="function.ziparchive-unchangeindex.html" >ZipArchive::unchangeIndex</A > -- Revert all changes done to an entry at the given index.</DT ><DT ><A HREF="function.ziparchive-unchangename.html" >ZipArchive::unchangeName</A > -- 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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.zip-close.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >zip_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >