Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 12122

php-manual-pt_BR-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
>Zlib - Funções de Compressão </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="ZipArchive::unchangeName"
HREF="function.ziparchive-unchangename.html"><LINK
REL="NEXT"
TITLE="gzclose"
HREF="function.gzclose.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.ziparchive-unchangename.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.gzclose.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.zlib"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>CLXXXVIII. Zlib - Funções de Compressão </H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN243885"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zlib.intro"
>Introdução</A
></H1
><P
>&#13;     Este módulo lhe possibilita ler e gerar transparentemente
     arquivos comprimidos do tipo gzip (.gz), através de muitas das
     funções <A
HREF="ref.filesystem.html"
>filesystem</A
>
     nas quais funcionam com arquivos gzip comprimidos (e arquivos não comprimidos
     também, mas não com sockets).
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      A versão 4.0.4 introduziu um fopen-wrapper para arquivos .gz, assim você
      pode usar uma URL especial <TT
CLASS="filename"
>zlib:</TT
> para acessar
      arquivos comprimidos transparentemente usando as funções f*() normais
      de acessos a arquivos se você colocar como prefixo no nome ou caminho
      <TT
CLASS="filename"
>zlib:</TT
> ao chamar <A
HREF="function.fopen.html"
><B
CLASS="function"
>fopen()</B
></A
>. Isto
      requer que você use uma biblioteca C em tempo de execução que
      tenha a função <TT
CLASS="literal"
>fopencookie()</TT
>. Até agora apenas a GNU libc
      parace ser a única biblioteca que tenha este recurso.
     </P
><P
>&#13;      No PHP 4.3.0, <TT
CLASS="filename"
>zlib:</TT
> foi modificado para
      <TT
CLASS="filename"
>compress.zlib://</TT
> para previnir ambiguidades com
      nomes de arquivos contendo caracteres ':'. A função
      <TT
CLASS="literal"
>fopencookie()</TT
> não é mais requerida.
      Maiores informações estão disponíveis em uma sessão sobre
      <A
HREF="wrappers.compression.html"
>a seção <I
>Compression Streams</I
>  Apêndice N</A
>.
     </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zlib.requirements"
>Dependências</A
></H1
><P
>&#13;     Este módulo usa as funções da <A
HREF="http://www.gzip.org/zlib/"
TARGET="_top"
>zlib</A
>
     por Jean-loup Gailly e Mark Adler. Você terá que usar uma versão zlib
     &#62;= à 1.0.9 com este módulo.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zlib.configuration"
>Configurações em execução</A
></H1
><P
>&#13;O comportamento dessas funções podem ser modificado pelas configurações do <TT
CLASS="filename"
>php.ini</TT
>.
</P
><P
>&#13;  A extensão zlib oferece a opção de comprimir transparentemente
  suas páginas em tempo real, se o navegador requisitante suportar isto.
  Então existem três opções no <A
HREF="configuration.html#configuration.file"
>arquivo de configuração</A
> <TT
CLASS="filename"
>php.ini</TT
>.
   <DIV
CLASS="table"
><A
NAME="AEN243912"
></A
><P
><B
>Tabela 1. Opções de Configuração da Zlib</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Nome</TH
><TH
>Padrão</TH
><TH
>Modificável</TH
><TH
>Modificação</TH
></TR
></THEAD
><TBODY
><TR
><TD
>zlib.output_compression</TD
><TD
>0</TD
><TD
>PHP_INI_ALL</TD
><TD
>Disponível desde o PHP 4.0.5.</TD
></TR
><TR
><TD
>zlib.output_compression_level</TD
><TD
>"-1"</TD
><TD
>PHP_INI_ALL</TD
><TD
>Disponível desde o PHP 4.3.0.</TD
></TR
><TR
><TD
>zlib.output_handler</TD
><TD
>""</TD
><TD
>PHP_INI_ALL</TD
><TD
>Disponível desde o PHP 4.3.0.</TD
></TR
></TBODY
></TABLE
></DIV
>
  Para mais detalhes e definições das constantes
 PHP_INI_*, veja <A
HREF="ini.html"
>Apêndice H</A
>.
 </P
><P
>&#13; Aqui está uma breve explicação das diretrizes de configuração.
 <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><A
NAME="ini.zlib.output-compression"
></A
><CODE
CLASS="parameter"
>zlib.output_compression</CODE
>
    booleano/inteiro</DT
><DD
><P
>&#13;     Serve para comprimir páginas de modo transparente. Se esta opção for
     mudada para "On" no <TT
CLASS="filename"
>php.ini</TT
> ou na configuração do Apache, as páginas serão
     comprimidas se o navegador enviar um cabeçalho "Accept-Encoding: gzip" ou
     "deflate". "Content-Encoding: gzip" (respectivamente
     "deflate") e cabeçalhos "Vary: Accept-Encoding" serão adicionados para
     a saida.
     Em tempo de execução, isso só pode ser definido antes de enviar qualquer saída.
    </P
><P
>&#13;     Esta opção também aceita valores inteiros em vez de valores booleanos
     "On"/"Off", usando isto você pode configurar o tamanho do buffer de saída
     (o padrão é 4KB).
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      <A
HREF="ref.outcontrol.html#ini.output-handler"
>output_handler</A
> deve estar
      vazio se a diretriz estiver configurada em 'On'! Em vez disto você deve usar zlib.output_handler.
     </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="ini.zlib.output-compression-level"
></A
><CODE
CLASS="parameter"
>zlib.output_compression_level</CODE
>
    inteiro</DT
><DD
><P
>&#13;     Nível de compressão usado para as saídas.
    </P
></DD
><DT
><A
NAME="ini.zlib.output-handler"
></A
><CODE
CLASS="parameter"
>zlib.output_handler</CODE
>
    <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
></DT
><DD
><P
>&#13;     Você não pode especificar tratamentos adicionais de saída se zlib.output_compression
     for ativado. Esta configuração faz o mesmo que a <A
HREF="ref.outcontrol.html#ini.output-handler"
>&#13;     output_handler</A
> mas em uma ordem diferente.
    </P
></DD
></DL
></DIV
>
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zlib.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="zlib.constants"
>Constantes pré-definidas</A
></H1
><P
>&#13;As contantes abaixo são definidas por esta extensão e somente
 estarão disponíveis quando a extensão foi compilada com o PHP
 ou carregada dinamicamente durante a execução.
</P
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>FORCE_GZIP</B
></TT
> 
      (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FORCE_DEFLATE</B
></TT
> 
      (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     
    </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zlib.examples"
>Exemplos</A
></H1
><P
>&#13;     Este exemplo abre um arquivo temporário e gera uma string teste
     dentro dele, então ela mostra o conteúdo deste arquivo duas vezes.
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN243987"
></A
><P
><B
>Exemplo 1. Pequeno Exemplo das funções Zlib</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$filename </font><font color="#007700">= </font><font color="#0000BB">tempnam </font><font color="#007700">(</font><font color="#DD0000">'/tmp'</font><font color="#007700">, </font><font color="#DD0000">'zlibteste'</font><font color="#007700">).</font><font color="#DD0000">'.gz'</font><font color="#007700">;<br />echo </font><font color="#DD0000">"&lt;html&gt;\n&lt;head&gt;&lt;/head&gt;\n&lt;body&gt;\n&lt;pre&gt;\n"</font><font color="#007700">;<br /></font><font color="#0000BB">$s </font><font color="#007700">= </font><font color="#DD0000">"Somente um teste, teste, teste, teste, teste, teste, teste, teste!\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// abre o arquivo para gerar ele com a compressão máxima<br /></font><font color="#0000BB">$zp </font><font color="#007700">= </font><font color="#0000BB">gzopen</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">, </font><font color="#DD0000">"w9"</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// escreve a string no arquivo<br /></font><font color="#0000BB">gzwrite</font><font color="#007700">(</font><font color="#0000BB">$zp</font><font color="#007700">, </font><font color="#0000BB">$s</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// fecha o arquivo<br /></font><font color="#0000BB">gzclose</font><font color="#007700">(</font><font color="#0000BB">$zp</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// abre o arquivo para leitura<br /></font><font color="#0000BB">$zp </font><font color="#007700">= </font><font color="#0000BB">gzopen</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">, </font><font color="#DD0000">"r"</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// lê 3 caracteres<br /></font><font color="#007700">echo </font><font color="#0000BB">gzread</font><font color="#007700">(</font><font color="#0000BB">$zp</font><font color="#007700">, </font><font color="#0000BB">3</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// mostra o conteúdo até o fim do arquivo e o fecha.<br /></font><font color="#0000BB">gzpassthru</font><font color="#007700">(</font><font color="#0000BB">$zp</font><font color="#007700">);<br /></font><font color="#0000BB">gzclose</font><font color="#007700">(</font><font color="#0000BB">$zp</font><font color="#007700">);<br /><br />echo </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// abre o arquivo e imprime o conteúdo dele (pela segunda vez).<br /></font><font color="#007700">if (</font><font color="#0000BB">readgzfile</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">) != </font><font color="#0000BB">strlen</font><font color="#007700">(</font><font color="#0000BB">$s</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Erro com as funções zlib!"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">unlink</font><font color="#007700">(</font><font color="#0000BB">$filename</font><font color="#007700">);<br />echo </font><font color="#DD0000">"&lt;/pre&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n"</font><font color="#007700">;<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
>Índice</B
></DT
><DT
><A
HREF="function.gzclose.html"
>gzclose</A
>&nbsp;--&nbsp;Fecha um ponteiro para um arquivo-gz</DT
><DT
><A
HREF="function.gzcompress.html"
>gzcompress</A
>&nbsp;--&nbsp;Comprime uma string</DT
><DT
><A
HREF="function.gzdecode.html"
>gzdecode</A
>&nbsp;--&nbsp;Decodes a gzip compressed string</DT
><DT
><A
HREF="function.gzdeflate.html"
>gzdeflate</A
>&nbsp;--&nbsp;Comprime uma string usando DEFLATE</DT
><DT
><A
HREF="function.gzencode.html"
>gzencode</A
>&nbsp;--&nbsp;Cria uma string comprimida com gzip</DT
><DT
><A
HREF="function.gzeof.html"
>gzeof</A
>&nbsp;--&nbsp;Testa para o fim de um ponteiro de arquivo-gz</DT
><DT
><A
HREF="function.gzfile.html"
>gzfile</A
>&nbsp;--&nbsp;Lê todo o arquivo-gz para uma matriz</DT
><DT
><A
HREF="function.gzgetc.html"
>gzgetc</A
>&nbsp;--&nbsp;Obtém um caractere de um ponteiro de arquivo-gz</DT
><DT
><A
HREF="function.gzgets.html"
>gzgets</A
>&nbsp;--&nbsp;Obtém uma linha de um ponteiro de arquivo</DT
><DT
><A
HREF="function.gzgetss.html"
>gzgetss</A
>&nbsp;--&nbsp;
     Obtém uma linha de um ponteiro de arquivo-gz e retira as tags HTML
    </DT
><DT
><A
HREF="function.gzinflate.html"
>gzinflate</A
>&nbsp;--&nbsp;Descomprime uma string usando DEFLATE</DT
><DT
><A
HREF="function.gzopen.html"
>gzopen</A
>&nbsp;--&nbsp;Abre um arquivo-gz</DT
><DT
><A
HREF="function.gzpassthru.html"
>gzpassthru</A
>&nbsp;--&nbsp;
     Envia todos os dados restantes em um ponteiro para arquivo-gz
    </DT
><DT
><A
HREF="function.gzputs.html"
>gzputs</A
>&nbsp;--&nbsp;Apelido para <A
HREF="function.gzwrite.html"
><B
CLASS="function"
>gzwrite()</B
></A
></DT
><DT
><A
HREF="function.gzread.html"
>gzread</A
>&nbsp;--&nbsp;Leitura de arquivos-gz segura para binários</DT
><DT
><A
HREF="function.gzrewind.html"
>gzrewind</A
>&nbsp;--&nbsp;Retorna ao início a posição de um ponteiro para um arquivo-gz</DT
><DT
><A
HREF="function.gzseek.html"
>gzseek</A
>&nbsp;--&nbsp;Move o ponteiro de um arquivo-gz</DT
><DT
><A
HREF="function.gztell.html"
>gztell</A
>&nbsp;--&nbsp;Indica a posição de leitura/gravação em um ponteiro para arquivo-gz</DT
><DT
><A
HREF="function.gzuncompress.html"
>gzuncompress</A
>&nbsp;--&nbsp;Descomprime uma string com DEFLATED</DT
><DT
><A
HREF="function.gzwrite.html"
>gzwrite</A
>&nbsp;--&nbsp;Escrita segura para binário em arquivo-gz</DT
><DT
><A
HREF="function.readgzfile.html"
>readgzfile</A
>&nbsp;--&nbsp;Mostra um arquivo-gz</DT
><DT
><A
HREF="function.zlib-get-coding-type.html"
>zlib_get_coding_type</A
>&nbsp;--&nbsp;Retorna o tipo de codificação para a compressão de saída</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.ziparchive-unchangename.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.gzclose.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>ZipArchive::unchangeName</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>gzclose</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>