Sophie

Sophie

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

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
>urlencode</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="URL"
HREF="ref.url.html"><LINK
REL="PREVIOUS"
TITLE="urldecode"
HREF="function.urldecode.html"><LINK
REL="NEXT"
TITLE="Variáveis, Funções"
HREF="ref.variables.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.urldecode.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.variables.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.urlencode"
></A
>urlencode</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN229349"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>urlencode&nbsp;--&nbsp;Codifica uma URL</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN229352"
></A
><H2
>Descrição</H2
>string <B
CLASS="methodname"
>urlencode</B
> ( string str )<BR
></BR
><P
>&#13;     Retorna uma string em que todos os caracteres não-alfanuméricos com exceção de
     <TT
CLASS="literal"
>-_.</TT
> são substituidos com um sinal de porcento
     (<TT
CLASS="literal"
>%</TT
>) siguido por dois digitos hexadecimais e espaços
     codificados como um sinal de (<TT
CLASS="literal"
>+</TT
>). É codificada
     do mesmo jeito que dados vindos de um formulário WWW é codificado, isto é,
     da mesma maneira que
     <TT
CLASS="literal"
>application/x-www-form-urlencoded</TT
>.
     Isto é diferente da codificação RFC1738 (veja
     <A
HREF="function.rawurlencode.html"
><B
CLASS="function"
>rawurlencode()</B
></A
>) nesta por razões historicas,
     espaços são codificados como sinais de mais(+). 
     Esta função é conveniente para codificar uma string que será 
     passada como parte de uma URL, como um meio de passar variáveis
     para a próxima pagina:
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN229366"
></A
><P
><B
>Exemplo 1. Exemplo <B
CLASS="function"
>urlencode()</B
></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">echo </font><font color="#DD0000">'&lt;a href="mycgi?foo='</font><font color="#007700">, </font><font color="#0000BB">urlencode</font><font color="#007700">(</font><font color="#0000BB">$userinput</font><font color="#007700">), </font><font color="#DD0000">'"&gt;'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Nota: Seja cuidadoso com variaveis que sejam iguais a entidades HTML.
     Coisas como &#38;amp, &#38;copy e &#38;pound são interpretados pelo
     browser e a entidade atual é usada ao invés do nome de variavel desejado.
     Isto é um problema obvio que o W3C vem falando a todos a anos.
     A referrência esta aqui:
     <A
HREF="http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2"
TARGET="_top"
>http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2</A
>. O PHP
     suporta que se mude o separador de argumentos para o ponto e vírgula
     sugerido pelo W3C através da diretiva de configuração arg_separator.
     Infelizmente a maior parte dos aplicativos não envia os dados neste formato.
     Um meio mais portável é usar &#38;amp; ao invés de
     &#38; como separador. Você não precisa mudar
     arg_separator para isto. Deixe como &#38;, mas simplesmente codifique as 
     suar URLs usando htmlentities(urlencode($data)).
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN229373"
></A
><P
><B
>Exemplo 2. Exemplo <B
CLASS="function"
>urlencode()</B
> e <A
HREF="function.htmlentities.html"
><B
CLASS="function"
>htmlentities()</B
></A
></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">echo </font><font color="#DD0000">'&lt;a href="mycgi?foo='</font><font color="#007700">, </font><font color="#0000BB">htmlentities</font><font color="#007700">(</font><font color="#0000BB">urlencode</font><font color="#007700">(</font><font color="#0000BB">$userinput</font><font color="#007700">)), </font><font color="#DD0000">'"&gt;'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Veja também <A
HREF="function.urldecode.html"
><B
CLASS="function"
>urldecode()</B
></A
>,
     <A
HREF="function.htmlentities.html"
><B
CLASS="function"
>htmlentities()</B
></A
>,
     <A
HREF="function.rawurldecode.html"
><B
CLASS="function"
>rawurldecode()</B
></A
> e
     <A
HREF="function.rawurlencode.html"
><B
CLASS="function"
>rawurlencode()</B
></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.urldecode.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="ref.variables.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>urldecode</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.url.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Variáveis, Funções</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>