Sophie

Sophie

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

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
>isset</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="Variáveis, Funções"
HREF="ref.variables.html"><LINK
REL="PREVIOUS"
TITLE="is_unicode"
HREF="function.is-unicode.html"><LINK
REL="NEXT"
TITLE="print_r"
HREF="function.print-r.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
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.is-unicode.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.print-r.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.isset"
></A
>isset</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN230259"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>isset&nbsp;--&nbsp;Informa se a variável foi iniciada</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN230262"
></A
><H2
>Descrição</H2
>bool <B
CLASS="methodname"
>isset</B
> ( mixed var [, mixed var [, ...]] )<BR
></BR
><P
>&#13;     Retorna <TT
CLASS="constant"
><B
>TRUE</B
></TT
> se <CODE
CLASS="parameter"
>var</CODE
> existir; <TT
CLASS="constant"
><B
>FALSE</B
></TT
> senão.
    </P
><P
>&#13;     Se a variável for destruída com <A
HREF="function.unset.html"
><B
CLASS="function"
>unset()</B
></A
>, ela não existirá
     mais. <B
CLASS="function"
>isset()</B
> retornará
     <TT
CLASS="constant"
><B
>FALSE</B
></TT
> se for usada em uma variável com o valor <TT
CLASS="constant"
><B
>NULL</B
></TT
>. Lembrando
     que no PHP um byte <TT
CLASS="constant"
><B
>NULL</B
></TT
> (<TT
CLASS="literal"
>"\0"</TT
>) é diferente da
     constante <TT
CLASS="constant"
><B
>NULL</B
></TT
>.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Alerta: </B
>
      <B
CLASS="function"
>isset()</B
> só trabalha com variáveis, qualquer outra coisa passada
      como parâmetro resultará em um erro de sintaxe (parse error).  Para testar
      <A
HREF="language.constants.html"
>constants</A
> você deverá usar a
      função <A
HREF="function.defined.html"
><B
CLASS="function"
>defined()</B
></A
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN230294"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$var </font><font color="#007700">= </font><font color="#DD0000">''</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Será interpretado como &amp;true; imprimindo o texto.<br /></font><font color="#007700">if (isset(</font><font color="#0000BB">$var</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"Essa variável existe."</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">// No próximo exemplo será usado var_dump para mostrar<br />// o valor de retorno de isset().<br /><br /></font><font color="#0000BB">$a </font><font color="#007700">= </font><font color="#DD0000">"teste"</font><font color="#007700">;<br /></font><font color="#0000BB">$b </font><font color="#007700">= </font><font color="#DD0000">"outrotest"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset(</font><font color="#0000BB">$a</font><font color="#007700">) );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// TRUE<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">, </font><font color="#0000BB">$b</font><font color="#007700">) ); </font><font color="#FF8000">// TRUE<br /><br /></font><font color="#007700">unset (</font><font color="#0000BB">$a</font><font color="#007700">);<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">) );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// FALSE<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">, </font><font color="#0000BB">$b</font><font color="#007700">) ); </font><font color="#FF8000">// FALSE<br /><br /></font><font color="#0000BB">$foo </font><font color="#007700">= </font><font color="#0000BB">NULL</font><font color="#007700">;<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$foo</font><font color="#007700">) );&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// FALSE<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
    </P
><P
>&#13;     Isto também serve para chaves associativas de matrizes:
     <DIV
CLASS="informalexample"
><P
></P
><A
NAME="AEN230297"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$a </font><font color="#007700">= array (</font><font color="#DD0000">'test' </font><font color="#007700">=&gt; </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">'hello' </font><font color="#007700">=&gt; </font><font color="#0000BB">NULL</font><font color="#007700">);<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">[</font><font color="#DD0000">'test'</font><font color="#007700">]) );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// TRUE<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">[</font><font color="#DD0000">'foo'</font><font color="#007700">]) );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// FALSE<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( isset (</font><font color="#0000BB">$a</font><font color="#007700">[</font><font color="#DD0000">'hello'</font><font color="#007700">]) );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// FALSE<br /><br />// A chave 'hello' é igual a NULL sendo considerada como inexistente<br />// Se quiser verificar o valor NULL da chave tente:<br /></font><font color="#0000BB">var_dump</font><font color="#007700">( </font><font color="#0000BB">array_key_exists</font><font color="#007700">(</font><font color="#DD0000">'hello'</font><font color="#007700">, </font><font color="#0000BB">$a</font><font color="#007700">) ); </font><font color="#FF8000">// TRUE<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
></P
></DIV
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>Este é um
 construtor de linguagem e não uma função, por isso não é possível chamá-lo através de
 <A
HREF="functions.variable-functions.html"
>funções variáveis</A
></P
></BLOCKQUOTE
></DIV
><P
>&#13;     Veja mais em <A
HREF="function.empty.html"
><B
CLASS="function"
>empty()</B
></A
>,
     <A
HREF="function.unset.html"
><B
CLASS="function"
>unset()</B
></A
>,
     <A
HREF="function.defined.html"
><B
CLASS="function"
>defined()</B
></A
>,
     <A
HREF="types.comparisons.html"
>Tabela de comparação de tipos</A
>,
     <A
HREF="function.array-key-exists.html"
><B
CLASS="function"
>array_key_exists()</B
></A
>,
     e controle o operador de controle erro
     <A
HREF="language.operators.errorcontrol.html"
>@</A
>.
    </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="function.is-unicode.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.print-r.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>is_unicode</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.variables.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>print_r</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>