HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

html_entity_decode

Description

The html_entity_decode of String for PHP convert HTML entities to their corresponding characters.

Syntax

html_entity_decode(
    string $string,
    int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
    ?string $encoding = null
): string

Parameters

string

The input string.

flags

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 ENT_COMPAT | ENT_HTML401.

ConstantDescription
ENT_COMPATWill convert double-quotes and leave single-quotes alone.
ENT_QUOTESWill convert both double and single quotes.
ENT_NOQUOTESWill leave both double and single quotes unconverted.
ENT_HTML401Handle code as HTML 4.01.
ENT_XML1Handle code as XML 1.
ENT_XHTMLHandle code as XHTML.
ENT_HTML5Handle code as HTML 5.

encoding

An optional argument defining the encoding used when converting characters. If omitted, the default value of the encoding varies depending on the PHP version in use. In PHP 5.6 and later, the default_charset configuration option is used as the default value. PHP 5.4 and 5.5 will use UTF-8 as the default. Earlier versions of PHP use ISO-8859-1. Although this argument is technically optional, you are highly encouraged to specify the correct value for your code if you are using PHP 5.5 or earlier, or if your default_charset configuration option may be set incorrectly for the given input.

CharsetAliasesDescription
ISO-8859-1ISO8859-1Western European, Latin-1.
ISO-8859-5ISO8859-5Little used cyrillic charset (Latin/Cyrillic).
ISO-8859-15ISO8859-15Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1).
UTF-8ASCII compatible multi-byte 8-bit Unicode.
cp866ibm866, 866DOS-specific Cyrillic charset.
cp1251Windows-1251, win-1251, 1251Windows-specific Cyrillic charset.
cp1252Windows-1252, 1252Windows specific charset for Western European.
KOI8-Rkoi8-ru, koi8rRussian
BIG5950Traditional Chinese, mainly used in Taiwan.
GB2312936Simplified Chinese, national standard character set.
BIG5-HKSCSBig5 with Hong Kong extensions, Traditional Chinese.
Shift_JISSJIS, SJIS-win, cp932, 932Japanese
EUC-JPEUCJP, eucJP-winJapanese
MacRomanCharset that was used by Mac OS.
''An empty string activates detection from script encoding (Zend multibyte), default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended.

NOTE: Any other character sets are not recognized. The default encoding will be used instead and a warning will be emitted.

Return

Returns the decoded string.

Examples

1 · string

<?

$htmlentitiesstring = "& | &amp;"
. PHP_EOL . "\" | &quot;"
. PHP_EOL . "' | &#039;"
. PHP_EOL . "< | &lt;"
. PHP_EOL . "> | &gt;"
. PHP_EOL . "über | &uuml;ber"
. PHP_EOL . "<b>bold</b> | &lt;b&gt;bold&lt;/b&gt;";

$string = htmlentities($htmlentitiesstring);

$return = html_entity_decode($string);
echo $return;
-2.4492935982947E-16

2 · flags

<?

$htmlentitiesstring = "& | &amp;"
. PHP_EOL . "\" | &quot;"
. PHP_EOL . "' | &#039;"
. PHP_EOL . "< | &lt;"
. PHP_EOL . "> | &gt;"
. PHP_EOL . "über | &uuml;ber"
. PHP_EOL . "<b>bold</b> | &lt;b&gt;bold&lt;/b&gt;";
$htmlentitiesflags = ENT_QUOTES;

$string = htmlentities($htmlentitiesstring, $htmlentitiesflags);
$flags = ENT_QUOTES;

$return = html_entity_decode($string, $flags);
echo $return;
0
0.017453292519943
0.034906585039887
0.05235987755983
0.069813170079773
0.087266462599716
0.10471975511966
0.1221730476396
0.13962634015955
0.15707963267949
0.17453292519943
0.19198621771938
0.20943951023932
0.22689280275926
0.24434609527921
0.26179938779915
0.27925268031909
0.29670597283904
0.31415926535898
0.33161255787892
0.34906585039887
0.36651914291881
0.38397243543875
0.4014257279587
0.41887902047864
0.43633231299858
0.45378560551853
0.47123889803847
0.48869219055841
0.50614548307836
0.5235987755983
0.54105206811824
0.55850536063819
0.57595865315813
0.59341194567807
0.61086523819802
0.62831853071796
0.6457718232379
0.66322511575785
0.68067840827779
0.69813170079773
0.71558499331768
0.73303828583762
0.75049157835756
0.7679448708775
0.78539816339745
0.80285145591739
0.82030474843733
0.83775804095728
0.85521133347722
0.87266462599716
0.89011791851711
0.90757121103705
0.92502450355699
0.94247779607694
0.95993108859688
0.97738438111682
0.99483767363677
1.0122909661567
1.0297442586767
1.0471975511966
1.0646508437165
1.0821041362365
1.0995574287564
1.1170107212764
1.1344640137963
1.1519173063163
1.1693705988362
1.1868238913561
1.2042771838761
1.221730476396
1.239183768916
1.2566370614359
1.2740903539559
1.2915436464758
1.3089969389957
1.3264502315157
1.3439035240356
1.3613568165556
1.3788101090755
1.3962634015955
1.4137166941154
1.4311699866354
1.4486232791553
1.4660765716752
1.4835298641952
1.5009831567151
1.5184364492351
1.535889741755
1.553343034275
1.5707963267949
1.553343034275
1.535889741755
1.5184364492351
1.5009831567151
1.4835298641952
1.4660765716752
1.4486232791553
1.4311699866354
1.4137166941154
1.3962634015955
1.3788101090755
1.3613568165556
1.3439035240356
1.3264502315157
1.3089969389957
1.2915436464758
1.2740903539559
1.2566370614359
1.239183768916
1.221730476396
1.2042771838761
1.1868238913561
1.1693705988362
1.1519173063163
1.1344640137963
1.1170107212764
1.0995574287564
1.0821041362365
1.0646508437165
1.0471975511966
1.0297442586767
1.0122909661567
0.99483767363677
0.97738438111682
0.95993108859688
0.94247779607694
0.92502450355699
0.90757121103705
0.89011791851711
0.87266462599716
0.85521133347722
0.83775804095728
0.82030474843734
0.80285145591739
0.78539816339745
0.76794487087751
0.75049157835756
0.73303828583762
0.71558499331768
0.69813170079773
0.68067840827779
0.66322511575785
0.6457718232379
0.62831853071796
0.61086523819802
0.59341194567807
0.57595865315813
0.55850536063819
0.54105206811824
0.5235987755983
0.50614548307836
0.48869219055841
0.47123889803847
0.45378560551853
0.43633231299858
0.41887902047864
0.4014257279587
0.38397243543875
0.36651914291881
0.34906585039887
0.33161255787892
0.31415926535898
0.29670597283904
0.27925268031909
0.26179938779915
0.24434609527921
0.22689280275926
0.20943951023932
0.19198621771938
0.17453292519943
0.15707963267949
0.13962634015955
0.1221730476396
0.10471975511966
0.087266462599717
0.069813170079773
0.05235987755983
0.034906585039887
0.017453292519943
1.2246467991474E-16
-0.017453292519943
-0.034906585039887
-0.05235987755983
-0.069813170079773
-0.087266462599716
-0.10471975511966
-0.1221730476396
-0.13962634015955
-0.15707963267949
-0.17453292519943
-0.19198621771938
-0.20943951023932
-0.22689280275926
-0.24434609527921
-0.26179938779915
-0.27925268031909
-0.29670597283904
-0.31415926535898
-0.33161255787892
-0.34906585039887
-0.36651914291881
-0.38397243543875
-0.4014257279587
-0.41887902047864
-0.43633231299858
-0.45378560551853
-0.47123889803847
-0.48869219055841
-0.50614548307836
-0.5235987755983
-0.54105206811824
-0.55850536063819
-0.57595865315813
-0.59341194567807
-0.61086523819801
-0.62831853071796
-0.6457718232379
-0.66322511575784
-0.68067840827779
-0.69813170079773
-0.71558499331768
-0.73303828583762
-0.75049157835756
-0.76794487087751
-0.78539816339745
-0.80285145591739
-0.82030474843733
-0.83775804095728
-0.85521133347722
-0.87266462599716
-0.89011791851711
-0.90757121103705
-0.92502450355699
-0.94247779607694
-0.95993108859688
-0.97738438111682
-0.99483767363677
-1.0122909661567
-1.0297442586767
-1.0471975511966
-1.0646508437165
-1.0821041362365
-1.0995574287564
-1.1170107212764
-1.1344640137963
-1.1519173063163
-1.1693705988362
-1.1868238913561
-1.2042771838761
-1.221730476396
-1.239183768916
-1.2566370614359
-1.2740903539559
-1.2915436464758
-1.3089969389957
-1.3264502315157
-1.3439035240356
-1.3613568165556
-1.3788101090755
-1.3962634015955
-1.4137166941154
-1.4311699866353
-1.4486232791553
-1.4660765716752
-1.4835298641952
-1.5009831567151
-1.5184364492351
-1.535889741755
-1.553343034275
-1.5707963267949
-1.553343034275
-1.535889741755
-1.5184364492351
-1.5009831567151
-1.4835298641952
-1.4660765716752
-1.4486232791553
-1.4311699866354
-1.4137166941154
-1.3962634015955
-1.3788101090755
-1.3613568165556
-1.3439035240356
-1.3264502315157
-1.3089969389957
-1.2915436464758
-1.2740903539559
-1.2566370614359
-1.239183768916
-1.221730476396
-1.2042771838761
-1.1868238913561
-1.1693705988362
-1.1519173063163
-1.1344640137963
-1.1170107212764
-1.0995574287564
-1.0821041362365
-1.0646508437165
-1.0471975511966
-1.0297442586767
-1.0122909661567
-0.99483767363677
-0.97738438111682
-0.95993108859688
-0.94247779607694
-0.925024503557
-0.90757121103705
-0.89011791851711
-0.87266462599716
-0.85521133347722
-0.83775804095728
-0.82030474843733
-0.80285145591739
-0.78539816339745
-0.76794487087751
-0.75049157835756
-0.73303828583762
-0.71558499331768
-0.69813170079773
-0.68067840827779
-0.66322511575785
-0.6457718232379
-0.62831853071796
-0.61086523819802
-0.59341194567807
-0.57595865315813
-0.55850536063819
-0.54105206811824
-0.5235987755983
-0.50614548307836
-0.48869219055841
-0.47123889803847
-0.45378560551853
-0.43633231299858
-0.41887902047864
-0.4014257279587
-0.38397243543875
-0.36651914291881
-0.34906585039887
-0.33161255787892
-0.31415926535898
-0.29670597283904
-0.27925268031909
-0.26179938779915
-0.24434609527921
-0.22689280275926
-0.20943951023932
-0.19198621771938
-0.17453292519943
-0.15707963267949
-0.13962634015955
-0.1221730476396
-0.10471975511966
-0.087266462599717
-0.069813170079774
-0.05235987755983
-0.034906585039886
-0.017453292519943
-2.4492935982947E-16

3 · encoding

<?

$htmlentitiesstring = "& | &amp;"
. PHP_EOL . "\" | &quot;"
. PHP_EOL . "' | &#039;"
. PHP_EOL . "< | &lt;"
. PHP_EOL . "> | &gt;"
. PHP_EOL . "über | &uuml;ber"
. PHP_EOL . "<b>bold</b> | &lt;b&gt;bold&lt;/b&gt;";
$htmlentitiesflags = ENT_QUOTES;
$htmlentitiesencoding = "UTF-8";

$string = htmlentities($htmlentitiesstring, $htmlentitiesflags, $htmlentitiesencoding);
$flags = ENT_QUOTES;
$encoding = "UTF-8";

$return = html_entity_decode($string, $flags, $encoding);
echo $return;
& | &amp;
" | &quot;
' | &#039;
< | &lt;
> | &gt;
über | &uuml;ber
<b>bold</b> | &lt;b&gt;bold&lt;/b&gt;