<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >htmlentities</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="String" HREF="ref.strings.html"><LINK REL="PREVIOUS" TITLE="html_entity_decode" HREF="function.html-entity-decode.html"><LINK REL="NEXT" TITLE="htmlspecialchars_decode" HREF="function.htmlspecialchars-decode.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.html-entity-decode.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.htmlspecialchars-decode.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.htmlentities" ></A >htmlentities</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN219280" ></A ><P > (PHP 3, PHP 4, PHP 5)</P >htmlentities -- Converte todos os caracteres para HTML entities </DIV ><DIV CLASS="refsect1" ><A NAME="AEN219283" ></A ><H2 >Descrição</H2 >string <B CLASS="methodname" >htmlentities</B > ( string string [, int quote_style [, string charset]] )<BR ></BR ><P > Esta função é idêntica a <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A > em tudo, exceto que todos os caracteres que tem caracteres HTML equivalentes são são traduzidos nesta realidade. Como <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A >, ele leva um segundo argumento opcional que indica o que seria feito com aspas simples e dupla. <TT CLASS="constant" ><B >ENT_COMPAT</B ></TT > (padrão) apenas converterá aspas duplas e deixará aspas-simples sozinha. <TT CLASS="constant" ><B >ENT_QUOTES</B ></TT > será convertido ambas aspas simples e dupla, e <TT CLASS="constant" ><B >ENT_NOQUOTES</B ></TT > deixará ambas desconvertidas. </P ><P > No presente momento, o conjunto de caracteres ISO-8859-1 é usado como padrão. Suporte para o segundo argumento opcional foi adicionado no PHP 3.0.17 e PHP 4.0.3. </P ><P > Como <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A >,ele leva um terceiro argumento opcional que define o conjunto de caracteres usados na conversão. Suporte para esse argumento foi adicionado no PHP 4.1.0. </P ><P > Não há o oposto desta função. Entretanto, você pode criar uma você próprio. Aqui está um exemplo de como fazer isso. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN219307" ></A ><P ><B >Exemplo 1. Oposto de <B CLASS="function" >htmlentities()</B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">function </font><font color="#0000BB">unhtmlentities </font><font color="#007700">(</font><font color="#0000BB">$string</font><font color="#007700">)<br />{<br /> </font><font color="#0000BB">$trans_tbl </font><font color="#007700">= </font><font color="#0000BB">get_html_translation_table </font><font color="#007700">(</font><font color="#0000BB">HTML_ENTITIES</font><font color="#007700">);<br /> </font><font color="#0000BB">$trans_tbl </font><font color="#007700">= </font><font color="#0000BB">array_flip </font><font color="#007700">(</font><font color="#0000BB">$trans_tbl</font><font color="#007700">);<br /> return </font><font color="#0000BB">strtr </font><font color="#007700">(</font><font color="#0000BB">$string</font><font color="#007700">, </font><font color="#0000BB">$trans_tbl</font><font color="#007700">);<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > Veja também <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A > e <A HREF="function.nl2br.html" ><B CLASS="function" >nl2br()</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.html-entity-decode.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.htmlspecialchars-decode.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >html_entity_decode</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.strings.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >htmlspecialchars_decode</TD ></TR ></TABLE ></DIV ></BODY ></HTML >