<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Output Control(Controle de Saída)</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="PDO_OCI DSN" HREF="ref.pdo-oci.connection.html"><LINK REL="NEXT" TITLE="flush" HREF="function.flush.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="ref.pdo-oci.connection.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.flush.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.outcontrol" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CXV. Output Control(Controle de Saída)</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN161060" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.intro" >Introdução</A ></H1 ><P > As funções de Controle de Saída permitem a você controlar quando a saída é enviada do script. Isto pode ser util em várias situações diversas, especialmente se você precisa enviar cabeçalhos para o browser depois que seu script começou a enviar dados. As funções de controle de saída não afetam os cabeçalhos enviados usando <A HREF="function.header.html" ><B CLASS="function" >header()</B ></A > ou <A HREF="function.setcookie.html" ><B CLASS="function" >setcookie()</B ></A >, somente funções como <A HREF="function.echo.html" ><B CLASS="function" >echo()</B ></A > e dados entre blocos de código PHP. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.requirements" >Dependências</A ></H1 ><P >Nenhuma biblioteca externa é necessária para compilar esta extensão.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.installation" >Instalação</A ></H1 ><P >Não há nenhuma instalação necessária para utilizar estas funções, elas fazem parte do núcleo do PHP.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.configuration" >Configurações em execução</A ></H1 ><P > O comportamento dessas funções podem ser modificado pelas configurações do <TT CLASS="filename" >php.ini</TT >. </P ><P > <DIV CLASS="table" ><A NAME="AEN161078" ></A ><P ><B >Tabela 1. Opções de configuração de controle de saída</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Nome</TH ><TH >Padrão</TH ><TH >Modificavel</TH ></TR ></THEAD ><TBODY ><TR ><TD >output_buffering</TD ><TD >"0"</TD ><TD >PHP_INI_PERDIR|PHP_INI_SYSTEM</TD ></TR ><TR ><TD >output_handler</TD ><TD >NULL</TD ><TD >PHP_INI_PERDIR|PHP_INI_SYSTEM</TD ></TR ><TR ><TD >implicit_flush</TD ><TD >"0"</TD ><TD >PHP_INI_PERDIR|PHP_INI_SYSTEM</TD ></TR ></TBODY ></TABLE ></DIV > Para maiores detalhes e definiç~es das constantes do PHP_INI_* veja <A HREF="function.ini-set.html" ><B CLASS="function" >ini_set()</B ></A >. </P ><P >Breve descrição das diretivas de configuração.</P ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><A NAME="ini.output-buffering" ></A ><CODE CLASS="parameter" >output_buffering</CODE > <A HREF="language.types.boolean.html" ><B CLASS="type" >boolean</B ></A >/<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></DT ><DD ><P > Você pode ativar o buffer de saída para todos os arquivos definindo esta dretiva para 'On'. Se você quiser limitar o tamanho do buffer para um certo limite - você pode usar um número máximo de bytes ao invés de 'On', como valor para esta diretiva (ex., output_buffering=4096). </P ></DD ><DT ><A NAME="ini.output-handler" ></A ><CODE CLASS="parameter" >output_handler</CODE > <A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></DT ><DD ><P > Você pode redirecionar toda a saída do seu script para uma função. Por exemplo, se você definir set output_handler para <A HREF="function.mb-output-handler.html" ><B CLASS="function" >mb_output_handler()</B ></A >, a codificação dos caracteres será transparentemente convertida para a codificação especificada. Definindo qualquer função para gerenciar a saída ativa o buffer de saída. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Você não pode usar <A HREF="function.mb-output-handler.html" ><B CLASS="function" >mb_output_handler()</B ></A > com <B CLASS="function" >ob_inconv_handler()</B > e você não pode usar <A HREF="function.ob-gzhandler.html" ><B CLASS="function" >ob_gzhandler()</B ></A > e <A HREF="ref.zlib.html#ini.zlib.output-compression" >zlib.output_compression</A >. </P ></BLOCKQUOTE ></DIV ></DD ><DT ><A NAME="ini.implicit-flush" ></A ><CODE CLASS="parameter" >implicit_flush</CODE > <A HREF="language.types.boolean.html" ><B CLASS="type" >boolean</B ></A ></DT ><DD ><P > <TT CLASS="constant" ><B >FALSE</B ></TT > por padrão. Mudando isto para <TT CLASS="constant" ><B >TRUE</B ></TT > diz ao PHP para dizer para a camada de saída descarregar a si mesma automaticamente a cada bloco de saída. Isto é equivalente a utilizar a função do <TT CLASS="literal" >PHP</TT > <A HREF="function.flush.html" ><B CLASS="function" >flush()</B ></A > a cada <A HREF="function.print.html" ><B CLASS="function" >print()</B ></A > ou <A HREF="function.echo.html" ><B CLASS="function" >echo()</B ></A > e a cada bloco de <TT CLASS="literal" >HTML</TT >. </P ><P > Quando estiver usando o <TT CLASS="literal" >PHP</TT > em um ambiente web, ativando esta opção tem uma séria implicação na performance e geralmente é recomendada apenas para debug. O valor padrão é <TT CLASS="constant" ><B >TRUE</B ></TT > quando operando sobre <TT CLASS="literal" >CLI SAPI</TT >. </P ><P > Veja também <A HREF="function.ob-implicit-flush.html" ><B CLASS="function" >ob_implicit_flush()</B ></A >. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.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="outcontrol.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="outcontrol.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN161151" ></A ><P ><B >Exemplo 1. Exemplo de Controle de saída</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />ob_start</font><font color="#007700">();<br />echo </font><font color="#DD0000">"Hello\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">setcookie</font><font color="#007700">(</font><font color="#DD0000">"cookiename"</font><font color="#007700">, </font><font color="#DD0000">"cookiedata"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">ob_end_flush</font><font color="#007700">();<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > No exmplo acima, a saída de <A HREF="function.echo.html" ><B CLASS="function" >echo()</B ></A > será guardada no bffer de saída até que <A HREF="function.ob-end-flush.html" ><B CLASS="function" >ob_end_flush()</B ></A > seja chamada. Em quanto isto, a chamada para <A HREF="function.setcookie.html" ><B CLASS="function" >setcookie()</B ></A > guadará o cookie sem causar um erro. (Normalmente você não pode enviar cabeçalhos para o browser depois que dados já foram enviados.) </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Quando atualizando a partir do PHP 4.1 (e 4.2) para 4.3 note que devido a um bug nas versões anteriores, você deve ter certeza que <TT CLASS="literal" >implict_flush</TT > esta em <TT CLASS="literal" >OFF</TT > no seu <TT CLASS="filename" >php.ini</TT >, se não qualquer saída com <A HREF="function.ob-start.html" ><B CLASS="function" >ob_start()</B ></A > não será escondida da saída. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="outcontrol.seealso" >Veja também</A ></H1 ><P > Veja também <A HREF="function.header.html" ><B CLASS="function" >header()</B ></A > e <A HREF="function.setcookie.html" ><B CLASS="function" >setcookie()</B ></A >. </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.flush.html" >flush</A > -- Descarrega o buffer de saída</DT ><DT ><A HREF="function.ob-clean.html" >ob_clean</A > -- Limpa (apaga) o buffer de saída </DT ><DT ><A HREF="function.ob-end-clean.html" >ob_end_clean</A > -- Limpa (apaga) o buffer de saída e desativa o buffer de saída </DT ><DT ><A HREF="function.ob-end-flush.html" >ob_end_flush</A > -- Descarrega (envia) o buffer de saída e desativa o buffer de saída </DT ><DT ><A HREF="function.ob-flush.html" >ob_flush</A > -- Descarrega (envia) o conteúdo do buffer de saída </DT ><DT ><A HREF="function.ob-get-clean.html" >ob_get_clean</A > -- Obtém o conteudo do buffer e exclui o buffer de saída atual </DT ><DT ><A HREF="function.ob-get-contents.html" >ob_get_contents</A > -- Retorna o conteúdo do buffer de saída </DT ><DT ><A HREF="function.ob-get-flush.html" >ob_get_flush</A > -- Flush the output buffer, return it as a string and turn off output buffering </DT ><DT ><A HREF="function.ob-get-length.html" >ob_get_length</A > -- Retorna o tamanho do buffer de saída </DT ><DT ><A HREF="function.ob-get-level.html" >ob_get_level</A > -- Retorna o nível do mecanismo de buffer de saída </DT ><DT ><A HREF="function.ob-get-status.html" >ob_get_status</A > -- Obtém a situação dos buffers de saída </DT ><DT ><A HREF="function.ob-gzhandler.html" >ob_gzhandler</A > -- Função de callback para ob_start para compactar com gzip o buffer de saída </DT ><DT ><A HREF="function.ob-implicit-flush.html" >ob_implicit_flush</A > -- Ativa ou desativa o descarregar implicito </DT ><DT ><A HREF="function.ob-list-handlers.html" >ob_list_handlers</A > -- List all output handlers in use </DT ><DT ><A HREF="function.ob-start.html" >ob_start</A > -- Ativa o buffer de saída</DT ><DT ><A HREF="function.output-add-rewrite-var.html" >output_add_rewrite_var</A > -- Add URL rewriter values </DT ><DT ><A HREF="function.output-reset-rewrite-vars.html" >output_reset_rewrite_vars</A > -- Reset URL rewriter values </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="ref.pdo-oci.connection.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.flush.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >PDO_OCI DSN</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >flush</TD ></TR ></TABLE ></DIV ></BODY ></HTML >