PHP html_entity_decode() 适用于PHP 4.3.0+,将HTML 实体转成字符。
html_entity_decode(包含HTML 实体的字符串, 可选如何解码引号, 可选字符编码集)
如果字符串中包含无法被识别的字符集将被忽略,并由 ISO-8859-1 代替。您可以使用 PHP htmlentities() 将HTML标签、引号及ASCII字符集外的其他字符串转换成HTML 实体。
立即学习“PHP免费学习笔记(深入)”;
如何解码引号: ENT_COMPAT - 默认。仅解码双引号。 ENT_QUOTES - 解码双引号和单引号。 ENT_NOQUOTES - 不解码任何引号。 字符编码集: ISO-8859-1 - 默认。西欧。 ISO-8859-15 - 西欧 (增加 Euro 符号以及法语、芬兰语字母)。 UTF-8 - ASCII 兼容多字节 8 比特 Unicode cp866 - DOS 专用 Cyrillic 字符集 cp1251 - Windows 专用 Cyrillic 字符集 cp1252 - Windows 专用西欧字符集 KOI8-R - 俄语 GB2312 - 简体中文,国家标准字符集 BIG5 - 繁体中文 BIG5-HKSCS - Big5 香港扩展 Shift_JIS - 日语 EUC-JP - 日语
PHP htmlspecialchars() 把 & ' " 转换成HTML 实体
PHP htmlspecialchars_decode() 把 & ' " HTML 实体反转成字符
PHP htmlentities() 把HTML标签字符转换为 HTML 实体
PHP html_entity_decode() 将所有HTML 实体转成字符原型
PHP html_entity_decode() 实例
虽然使用PHP htmlentities() 只能对HTML标签字符串进行HTML 实体化,但是您可以使用PHP html_entity_decode() 对所有HTML 实体化的字符进行转换成字符。
<?<span php><span function> showCode(<span>){<span return> <span str_replace>('&', '&', <span><span><span><span>
<span> = '-->"E.V-Get.com"<--'<span><span> = <span htmlentities>(<span>,<span ent_quotes><span echo> showCode(<span><span><span><span>
<span> = <span html_entity_decode>(<span><span><span echo> showCode(<span><span><span><span>
<span>=<span html_entity_decode>(<span>,<span ent_noquotes><span echo> showCode(<span><span><span><span>
?></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
原文:http://e.v-get.com/w3c/PHP_html_entity_decode.html










