Sophie

Sophie

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

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
>Sintaxe Básica</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 da Linguagem"
HREF="langref.html"><LINK
REL="PREVIOUS"
TITLE="Referência da Linguagem"
HREF="langref.html"><LINK
REL="NEXT"
TITLE="Separação de instruções"
HREF="language.basic-syntax.instruction-separation.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="chapter"
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="langref.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.basic-syntax.instruction-separation.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="language.basic-syntax"
>Capítulo 10. Sintaxe Básica</A
></H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Índice</B
></DT
><DT
><A
HREF="language.basic-syntax.html#language.basic-syntax.phpmode"
>Escapando o HTML</A
></DT
><DT
><A
HREF="language.basic-syntax.instruction-separation.html"
>Separação de instruções</A
></DT
><DT
><A
HREF="language.basic-syntax.comments.html"
>Comentários</A
></DT
></DL
></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.basic-syntax.phpmode"
>Escapando o HTML</A
></H1
><P
>&#13;    Quando o PHP interpreta um arquivo, ele procura pelas tags de abertura e fechamento,
    as quais indicam para o PHP começar e parar de interpretar o código
    entre elas. interpretar desta maneira permite ao PHP ser embutido em todos
    os tipos de documentos diferentes, já que tudo fora o par
    de tags de abertura e fechamento é ignorado pelo interpretador do PHP.
    A maioria das vezes você verá o PHP embutido em documentos HTML
    como neste exemplo.
    <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN2700"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
&lt;p&gt;Isto vai ser ignorado.&lt;/p&gt;<br /><font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">'Enquanto isto vai ser interpretado.'</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br /></font>&lt;p&gt;Isto também vai ser ignorado.&lt;/p&gt;</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
   </P
><P
>&#13;    Você também pode usar estruturas mais avançadas:
    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2703"
></A
><P
><B
>Exemplo 10-1. Escapando de modo avançado</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">if (</font><font color="#0000BB">$expression</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">?&gt;<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&lt;strong&gt;Isto é.&lt;/strong&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000BB">&lt;?php<br /></font><font color="#007700">} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">?&gt;<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&lt;strong&gt;Isto é false.&lt;/strong&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000BB">&lt;?php<br /></font><font color="#007700">}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    Isto funciona como o esperado, porque o quando PHP atinge o ?&#62; fechando
    as tags, ele simplesmente começa a enviar para a saída qualquer coisa que encontre até
    que atinja outra tag de abertura. O exemplo dado aqui é resumido, claro,
    mas para escrever grandes blocos de texto, sair do modo de interpretação
    do PHP é geralmente mais eficiente do que enviar todo
    o texto atráves de <A
HREF="function.echo.html"
><B
CLASS="function"
>echo()</B
></A
> ou
    <A
HREF="function.print.html"
><B
CLASS="function"
>print()</B
></A
>.
   </P
><P
>&#13;    Existem quatro diferentes pares de tags de abertura e fechamento
    que podem ser usados com o PHP. Duas dessas, &#60;?php ?&#62; e
    &#60;script language="php"&#62; &#60;/script&#62;, estão sempre disponíveis.
    As outras duas são tags curtas e tags no estilo <SPAN
CLASS="productname"
>ASP</SPAN
>,
    e podem ser ativadas e desativadas a partir do arquivo
    de configuração <TT
CLASS="filename"
>php.ini</TT
>. Assim, enquanto algumas pessoas acham as tags
    curtas e tags no estilo <SPAN
CLASS="productname"
>ASP</SPAN
> conveniente,  elas
    são menos portáveis, e geralmente não recomendadas.
    <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Também note que se você esta embutindo o PHP no XML ou XHTML
      você irá precisar usar as tags &#60;?php ?&#62; para permanecer
      cumprindo com os padrões.
     </P
></BLOCKQUOTE
></DIV
>
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN2715"
></A
><P
><B
>Exemplo 10-2. Abrindo e Fechando as Tags do PHP</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
1.&nbsp;&nbsp;<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">'se você quer servir documentos XHTML ou XML, faça assim'</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br /></font><br />2.&nbsp;&nbsp;<font color="#0000BB">&lt;script language="php"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">echo </font><font color="#DD0000">'alguns editores (como FrontPage) não<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gostam de instruções de processamento'</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">&lt;/script&gt;<br /></font><br />3.&nbsp;&nbsp;<font color="#0000BB">&lt;? </font><font color="#007700">echo </font><font color="#DD0000">'esta é a mais simples, uam instrução de processamento SGML'</font><font color="#007700">; </font><font color="#0000BB">?&gt;<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000BB">&lt;?= expressão ?&gt;</font> Isto é um atalho para "<font color="#0000BB">&lt;? </font><font color="#007700">echo </font><font color="#0000BB">expressão ?&gt;</font>"<br /><br />4.&nbsp;&nbsp;&lt;% echo 'Você pode opcionalmente usar tags no estilo ASP'; %&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;%= $variavel; # Isto é um atalho para "&lt;% echo . . ." %&gt;</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    Enquanto as tags vistas nos exemplos um e dois estão
    ambas sempre disponíveis, o exemplo um é mais comumente
    usado, e recomendado, das duas.
   </P
><P
>&#13;    Tags curtas (exemplo três) estão disponíveis apenas quando são ativadas
    pela configuração <A
HREF="ini.core.html#ini.short-open-tag"
>short_open_tag</A
>
    no arquivo <TT
CLASS="filename"
>php.ini</TT
> ou se o PHP foi configurado com
    a opção <CODE
CLASS="option"
>--enable-short-tags</CODE
>.
    <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Se você esta usando o PHP 3 você pode também ativar as tags curtas
      atráves da função <B
CLASS="function"
>short_tags()</B
>. <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>Isto
      esta disponível apenas no PHP 3!</I
></SPAN
>
     </P
></BLOCKQUOTE
></DIV
>
   </P
><P
>&#13;    Tags no estilo <SPAN
CLASS="productname"
>ASP</SPAN
> (exemplo quatro estão disponíveis apenas
    quando elas estão ativadas atráves da diretiva de configuração <A
HREF="ini.core.html#ini.asp-tags"
>asp_tags</A
>
    no arquivo <TT
CLASS="filename"
>php.ini</TT
>.
    <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Suporte a tags <SPAN
CLASS="productname"
>ASP</SPAN
> foi adicionado no 3.0.4.
     </P
></BLOCKQUOTE
></DIV
>
   </P
><P
>&#13;    <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      O uso de tags curtas deve ser evitado ao desenvolver aplicações
      ou bibliotecas que serão redistribuidas, ou serão usadas em
      servidores PHP que não estão sobre o seu controle, porque as tags curtas
      podem não ser suportadas no servidor em questão. Para código portavel,
      redistribuível, tenha certesa de não usar tags curtas.
     </P
></BLOCKQUOTE
></DIV
>
   </P
></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="langref.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="language.basic-syntax.instruction-separation.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Referência da Linguagem</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="langref.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Separação de instruções</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>