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.
Constant | Description |
---|---|
ENT_COMPAT | Will convert double-quotes and leave single-quotes alone. |
ENT_QUOTES | Will convert both double and single quotes. |
ENT_NOQUOTES | Will leave both double and single quotes unconverted. |
ENT_HTML401 | Handle code as HTML 4.01. |
ENT_XML1 | Handle code as XML 1. |
ENT_XHTML | Handle code as XHTML. |
ENT_HTML5 | Handle 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.
Charset | Aliases | Description |
---|---|---|
ISO-8859-1 | ISO8859-1 | Western European, Latin-1. |
ISO-8859-5 | ISO8859-5 | Little used cyrillic charset (Latin/Cyrillic). |
ISO-8859-15 | ISO8859-15 | Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1). |
UTF-8 | ASCII compatible multi-byte 8-bit Unicode. | |
cp866 | ibm866, 866 | DOS-specific Cyrillic charset. |
cp1251 | Windows-1251, win-1251, 1251 | Windows-specific Cyrillic charset. |
cp1252 | Windows-1252, 1252 | Windows specific charset for Western European. |
KOI8-R | koi8-ru, koi8r | Russian |
BIG5 | 950 | Traditional Chinese, mainly used in Taiwan. |
GB2312 | 936 | Simplified Chinese, national standard character set. |
BIG5-HKSCS | Big5 with Hong Kong extensions, Traditional Chinese. | |
Shift_JIS | SJIS, SJIS-win, cp932, 932 | Japanese |
EUC-JP | EUCJP, eucJP-win | Japanese |
MacRoman | Charset 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 = "& | &" . PHP_EOL . "\" | "" . PHP_EOL . "' | '" . PHP_EOL . "< | <" . PHP_EOL . "> | >" . PHP_EOL . "über | über" . PHP_EOL . "<b>bold</b> | <b>bold</b>"; $string = htmlentities($htmlentitiesstring); $return = html_entity_decode($string); echo $return;
-2.4492935982947E-16
2 · flags
<? $htmlentitiesstring = "& | &" . PHP_EOL . "\" | "" . PHP_EOL . "' | '" . PHP_EOL . "< | <" . PHP_EOL . "> | >" . PHP_EOL . "über | über" . PHP_EOL . "<b>bold</b> | <b>bold</b>"; $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 = "& | &" . PHP_EOL . "\" | "" . PHP_EOL . "' | '" . PHP_EOL . "< | <" . PHP_EOL . "> | >" . PHP_EOL . "über | über" . PHP_EOL . "<b>bold</b> | <b>bold</b>"; $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;
& | & " | " ' | ' < | < > | > über | über <b>bold</b> | <b>bold</b>
Links
String
- addcslashes
- addslashes
- bin2hex
- chop
- chr
- chunk_split
- convert_uudecode
- convert_uuencode
- count_chars
- crc32
- crypt
- echo
- explode
- fprintf
- get_html_translation_table
- hebrev
- hebrevc
- hex2bin
- htmlentities
- htmlspecialchars
- htmlspecialchars_decode
- implode
- join
- lcfirst
- levenshtein
- localeconv
- ltrim
- md5
- md5_file
- metaphone
- nl_langinfo
- nl2br
- number_format
- ord
- parse_str
- printf
- quoted_printable_decode
- quoted_printable_encode
- quotemeta
- rtrim
- setlocale
- sha1
- sha1_file
- similar_text
- soundex
- sprintf
- sscanf
- str_contains
- str_decrement
- str_ends_with
- str_getcsv
- str_increment
- str_ireplace
- str_pad
- str_repeat
- str_replace
- str_rot13
- str_shuffle
- str_split
- str_starts_with
- str_word_count
- strcasecmp
- strchr
- strcmp
- strcoll
- strcspn
- strip_tags
- stripcslashes
- stripos
- stripslashes
- stristr
- strlen
- strnatcasecmp
- strnatcmp
- strncasecmp
- strncmp
- strpbrk
- strpos
- strrchr
- strrev
- strripos
- strrpos
- strspn
- strstr
- strtok
- strtolower
- strtoupper
- strtr
- substr
- substr_compare
- substr_count
- substr_replace
- trim
- ucfirst
- ucwords
- vfprintf
- vprintf
- vsprintf
- wordwrap