Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 834

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>html_entity_decode</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Funciones de cadenas"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="hebrevc"
HREF="function.hebrevc.html"><LINK
REL="NEXT"
TITLE="htmlentities"
HREF="function.htmlentities.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></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 de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.hebrevc.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.htmlentities.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.html-entity-decode"
></A
>html_entity_decode</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN74627"
></A
><P
>    (PHP 4 &#62;= 4.3.0)</P
>html_entity_decode&nbsp;--&nbsp;
     Convert all HTML entities to their applicable characters
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN74630"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>html_entity_decode</B
> ( string string [, int quote_style [, string charset]])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>html_entity_decode()</B
> is the opposite of
     <A
HREF="function.htmlentities.html"
><B
CLASS="function"
>htmlentities()</B
></A
> in that it converts all HTML entities
     to their applicable characters from <TT
CLASS="parameter"
><I
>string</I
></TT
>.
    </P
><P
>&#13;     The optional second <TT
CLASS="parameter"
><I
>quote_style</I
></TT
> parameter lets 
     you define what will be done with 'single' and "double" quotes.  It takes 
     on one of three constants with the default being 
     <TT
CLASS="constant"
><B
>ENT_COMPAT</B
></TT
>:
     <DIV
CLASS="table"
><A
NAME="AEN74651"
></A
><P
><B
>Tabla 1. Available <TT
CLASS="parameter"
><I
>quote_style</I
></TT
> constants</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>Constant Name</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="constant"
><B
>ENT_COMPAT</B
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Will convert double-quotes and leave single-quotes alone.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="constant"
><B
>ENT_QUOTES</B
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Will convert both double and single quotes.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="constant"
><B
>ENT_NOQUOTES</B
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Will leave both double and single quotes unconverted.</TD
></TR
></TBODY
></TABLE
></DIV
>
    </P
><P
>&#13;     The ISO-8859-1 character set is used as default for the optional third
     <TT
CLASS="parameter"
><I
>charset</I
></TT
>.  This defines the character set used in
     conversion.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN74675"
></A
><P
><B
>Ejemplo 1. Decoding html entities</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$orig = "I'll \"walk\" the &#60;b&#62;dog&#60;/b&#62; now";

$a = htmlentities($orig);

$b = html_entity_decode($a);

echo $a; // I'll &#38;quot;walk&#38;quot; the &#38;lt;b&#38;gt;dog&#38;lt;/b&#38;gt; now

echo $b; // I'll "walk" the &#60;b&#62;dog&#60;/b&#62; now


// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities ($string)
{
    $trans_tbl = get_html_translation_table (HTML_ENTITIES);
    $trans_tbl = array_flip ($trans_tbl);
    return strtr ($string, $trans_tbl);
}

$c = unhtmlentities($a);

echo $c; // I'll "walk" the &#60;b&#62;dog&#60;/b&#62; now

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
       You might wonder why trim(html_entity_decode('&#38;nbsp;')); doesn't
       reduce the string to an empty string, that's because the '&#38;nbsp;'
       entity is not ASCII code 32 (which is stripped by
       <A
HREF="function.trim.html"
><B
CLASS="function"
>trim()</B
></A
>) but ASCII code 160 (0xa0) in the default ISO
       8859-1 characterset.
      </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     See also <A
HREF="function.htmlentities.html"
><B
CLASS="function"
>htmlentities()</B
></A
>,
     <A
HREF="function.htmlspecialchars.html"
><B
CLASS="function"
>htmlspecialchars()</B
></A
>,
     <A
HREF="function.get-html-translation-table.html"
><B
CLASS="function"
>get_html_translation_table()</B
></A
>, 
     <A
HREF="function.htmlspecialchars.html"
><B
CLASS="function"
>htmlspecialchars()</B
></A
> and <A
HREF="function.urldecode.html"
><B
CLASS="function"
>urldecode()</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.hebrevc.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.htmlentities.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>hebrevc</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>htmlentities</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>