PHP Html_entity_decode () applies to PHP 4.3.0+, which converts HTML entities into characters.
Html_entity_decode (a string containing an HTML entity, optionally how to decode quotes, optional character encoding sets)
If the string contains a character set that cannot be recognized, it is ignored and replaced by Iso-8859-1. You can use PHP htmlentities () to convert HTML tags, quotes, and other strings outside of the ASCII character set to HTML entities.
How to decode quotes:
Ent_compat-Default. Decodes only double quotes.
Ent_quotes-decodes double quotes and single quotes.
Ent_noquotes-does not decode any quotes.
Character encoding set:
Iso-8859-1-Default. Western europe.
Iso-8859-15-Western Europe (add Euro symbols and French, Finnish letters).
UTF-8-ASCII compatible Multi-byte 8-bit Unicode
Cp866-dos dedicated Cyrillic Character Set
Cp1251-windows dedicated Cyrillic Character Set
Cp1252-windows Special Western European character set
Koi8-r-Russian
GB2312-Simplified Chinese, national standard character set
BIG5-Traditional Chinese
Big5-hkscs-big5 Hong Kong expansion
Shift_JIS-Japanese
EUC-JP-Japanese
PHP htmlspecialchars () Convert & ' < and > to HTML entities
PHP Htmlspecialchars_decode () Invert & ' "< and > HTML entities into characters
PHP htmlentities () converts HTML tag characters to HTML entities
PHP Html_entity_decode () turns all HTML entities into character prototypes
PHP Html_entity_decode () instance
Although using PHP htmlentities () can only be HTML materialized for HTML tag strings, you can use PHP Html_entity_decode () to convert all HTML-materialized characters to characters.
<?php
function ShowCode ($s) {return str_replace (' & ', ' & ', $s);}
Since the output is still the original character after being converted into an HTML entity, the & is replaced with & You can output the source code
format, and if you don't use this replacement, you can see the same result by looking at the output $html source code.
$weigeti = '--> ' e.v-get.com ' <--';
$html = Htmlentities ($weigeti, ent_quotes);
echo ShowCode ($html);
Output "-->" e.v-get.com"<--"
$entity = Html_entity_decode ($html);
echo ShowCode ($entity);
Output "-->" e.v-get.com "<--"
$entity _noquotes=html_entity_decode ($html, ent_noquotes);
Echo ShowCode ($entity _noquotes);
Output "-->" e.v-get.com"<--"
?>
Original: http://e.v-get.com/w3c/PHP_html_entity_decode.html
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/