2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 09:08:43 +00:00
|
|
|
<!-- $Revision$ -->
|
2020-12-05 14:30:42 +00:00
|
|
|
<refentry xml:id="function.html-entity-decode" xmlns="http://docbook.org/ns/docbook">
|
2007-06-15 19:01:26 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>html_entity_decode</refname>
|
2018-08-02 22:23:22 +00:00
|
|
|
<refpurpose>Convert HTML entities to their corresponding characters</refpurpose>
|
2007-06-15 19:01:26 +00:00
|
|
|
</refnamediv>
|
2007-06-15 19:01:57 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-06-15 19:01:26 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>html_entity_decode</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
2020-12-05 14:30:42 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>ENT_COMPAT</constant></initializer></methodparam>
|
|
|
|
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
|
2007-06-15 19:01:26 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>html_entity_decode</function> is the opposite of
|
2018-08-02 22:23:22 +00:00
|
|
|
<function>htmlentities</function> in that it converts HTML entities
|
|
|
|
in the <parameter>string</parameter> to their corresponding characters.
|
2007-06-15 19:01:26 +00:00
|
|
|
</para>
|
2012-06-21 13:17:23 +00:00
|
|
|
<para>
|
|
|
|
More precisely, this function decodes all the entities (including all numeric
|
|
|
|
entities) that a) are necessarily valid for the chosen document type — i.e.,
|
|
|
|
for XML, this function does not decode named entities that might be defined
|
|
|
|
in some DTD — and b) whose character or characters are in the coded character
|
|
|
|
set associated with the chosen encoding and are permitted in the chosen
|
|
|
|
document type. All other entities are left as is.
|
|
|
|
</para>
|
2007-06-15 19:01:57 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
2007-06-15 19:01:26 +00:00
|
|
|
<para>
|
2007-06-15 19:01:57 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>string</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The input string.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2012-01-28 14:32:07 +00:00
|
|
|
<term><parameter>flags</parameter></term>
|
2007-06-15 19:01:57 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2012-01-28 14:32:07 +00:00
|
|
|
A bitmask of one or more of the following flags, which specify how to handle quotes and
|
|
|
|
which document type to use. The default is <literal>ENT_COMPAT | ENT_HTML401</literal>.
|
2007-06-15 19:01:57 +00:00
|
|
|
<table>
|
2012-01-28 14:32:07 +00:00
|
|
|
<title>Available <parameter>flags</parameter> constants</title>
|
2007-06-15 19:01:57 +00:00
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>Constant Name</entry>
|
|
|
|
<entry>Description</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_COMPAT</constant></entry>
|
|
|
|
<entry>Will convert double-quotes and leave single-quotes alone.</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_QUOTES</constant></entry>
|
|
|
|
<entry>Will convert both double and single quotes.</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_NOQUOTES</constant></entry>
|
|
|
|
<entry>Will leave both double and single quotes unconverted.</entry>
|
|
|
|
</row>
|
2012-01-28 14:32:07 +00:00
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_HTML401</constant></entry>
|
|
|
|
<entry>
|
|
|
|
Handle code as HTML 4.01.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_XML1</constant></entry>
|
|
|
|
<entry>
|
|
|
|
Handle code as XML 1.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_XHTML</constant></entry>
|
|
|
|
<entry>
|
|
|
|
Handle code as XHTML.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>ENT_HTML5</constant></entry>
|
|
|
|
<entry>
|
|
|
|
Handle code as HTML 5.
|
|
|
|
</entry>
|
|
|
|
</row>
|
2007-06-15 19:01:57 +00:00
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2012-02-16 23:55:01 +00:00
|
|
|
<term><parameter>encoding</parameter></term>
|
2007-06-15 19:01:57 +00:00
|
|
|
<listitem>
|
2014-08-28 03:36:23 +00:00
|
|
|
&strings.parameter.encoding;
|
2007-06-15 19:01:57 +00:00
|
|
|
&reference.strings.charsets;
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
Returns the decoded string.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2020-12-05 14:30:42 +00:00
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>8.0.0</entry>
|
|
|
|
<entry>
|
|
|
|
<parameter>encoding</parameter> is nullable now.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</refsect1>
|
|
|
|
|
2007-06-15 19:01:57 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2007-06-15 19:01:26 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Decoding HTML entities</title>
|
|
|
|
<programlisting role="php">
|
2002-11-18 09:28:42 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$orig = "I'll \"walk\" the <b>dog</b> now";
|
|
|
|
|
|
|
|
$a = htmlentities($orig);
|
|
|
|
|
|
|
|
$b = html_entity_decode($a);
|
|
|
|
|
|
|
|
echo $a; // I'll "walk" the <b>dog</b> now
|
|
|
|
|
|
|
|
echo $b; // I'll "walk" the <b>dog</b> now
|
|
|
|
?>
|
|
|
|
]]>
|
2007-06-15 19:01:26 +00:00
|
|
|
</programlisting>
|
2007-06-15 19:01:57 +00:00
|
|
|
</example>
|
2007-06-15 19:01:26 +00:00
|
|
|
</para>
|
2007-06-15 19:01:57 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
You might wonder why trim(html_entity_decode('&nbsp;')); doesn't
|
|
|
|
reduce the string to an empty string, that's because the '&nbsp;'
|
|
|
|
entity is not ASCII code 32 (which is stripped by
|
|
|
|
<function>trim</function>) but ASCII code 160 (0xa0) in the default ISO
|
2012-02-16 23:55:01 +00:00
|
|
|
8859-1 encoding.
|
2007-06-15 19:01:57 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2007-06-15 19:01:26 +00:00
|
|
|
<para>
|
2007-06-15 19:01:57 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>htmlentities</function></member>
|
|
|
|
<member><function>htmlspecialchars</function></member>
|
|
|
|
<member><function>get_html_translation_table</function></member>
|
|
|
|
<member><function>urldecode</function></member>
|
|
|
|
</simplelist>
|
2007-06-15 19:01:26 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-06-15 19:01:57 +00:00
|
|
|
|
2007-06-15 19:01:26 +00:00
|
|
|
</refentry>
|
2002-11-18 09:28:42 +00:00
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-11-18 09:28:42 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|