Sophie

Sophie

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

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
>continue</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="Estruturas de Controle"
HREF="language.control-structures.html"><LINK
REL="PREVIOUS"
TITLE="break"
HREF="control-structures.break.html"><LINK
REL="NEXT"
TITLE="switch"
HREF="control-structures.switch.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="sect1"
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="control-structures.break.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Capítulo 16. Estruturas de Controle</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="control-structures.switch.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="control-structures.continue"
><TT
CLASS="literal"
>continue</TT
></A
></H1
><P
>&#13;    <TT
CLASS="literal"
>continue</TT
> é usado dentro de estruturas de loops
    para saltar o resto da iteração do loop atual e continuar a execução
    na avaliação e no início da próxima iteração.
   </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
     Note que no PHP a instrução
     <A
HREF="control-structures.switch.html"
>switch</A
> é
     considerada uma estrutura de loop quando relacionada ao comando
     <TT
CLASS="literal"
>continue</TT
>.
    </P
></BLOCKQUOTE
></DIV
><P
>&#13;    <TT
CLASS="literal"
>continue</TT
> aceita um argumento numérico opcional que diz
    a ele de quantos níveis de loops aninhados ele deve saltar
    até o fim.
   </P
><P
>&#13;    <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN4780"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">while (list (</font><font color="#0000BB">$key</font><font color="#007700">, </font><font color="#0000BB">$value</font><font color="#007700">) = </font><font color="#0000BB">each </font><font color="#007700">(</font><font color="#0000BB">$arr</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;if (!(</font><font color="#0000BB">$key </font><font color="#007700">% </font><font color="#0000BB">2</font><font color="#007700">)) { </font><font color="#FF8000">// pula itens pares<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">do_something_odd </font><font color="#007700">(</font><font color="#0000BB">$value</font><font color="#007700">);<br />}<br /><br /></font><font color="#0000BB">$i </font><font color="#007700">= </font><font color="#0000BB">0</font><font color="#007700">;<br />while (</font><font color="#0000BB">$i</font><font color="#007700">++ &lt; </font><font color="#0000BB">5</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Fora&lt;br /&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;while (</font><font color="#0000BB">1</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"&amp;nbsp;&amp;nbsp;Meio&lt;br /&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (</font><font color="#0000BB">1</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"&amp;nbsp;&amp;nbsp;Dentro&lt;br /&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue </font><font color="#0000BB">3</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">"Isto nunca será exibido.&lt;br /&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Nem isso.&lt;br /&gt;\n"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
    </P
><P
>&#13;     Omitindo o ponto e vírgula depois do <TT
CLASS="literal"
>continue</TT
> pode resultar em
     confusão. Este é um exemplo do que você não deve fazer.
    </P
><P
>&#13;     <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN4785"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;</font><font color="#007700">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">5</font><font color="#007700">; ++</font><font color="#0000BB">$i</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$i </font><font color="#007700">== </font><font color="#0000BB">2</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"$i</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />&nbsp;&nbsp;}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;       Um resultado esperado poderia ser:
      </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>0
1
3
4</PRE
></TD
></TR
></TABLE
><P
>&#13;       mas esse script somente exibirá:
      </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>2</PRE
></TD
></TR
></TABLE
><P
>&#13;       porque o valor de retorno da chamada a <A
HREF="function.print.html"
><B
CLASS="function"
>print()</B
></A
>
       é <TT
CLASS="literal"
>int(1)</TT
>, e então ele se parecerá como
       o argumento numérico opcional mencionado acima.
      </P
><P
></P
></DIV
>
    </P
></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="control-structures.break.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="control-structures.switch.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><TT
CLASS="literal"
>break</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.control-structures.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><TT
CLASS="literal"
>switch</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>