PHP html_entity_decode() 函数把 HTML 实体转换为字符

今天在页面<meta name="Description" content="" />中调用数据库内容是发现内容中有一些html实体,如&mdash;&mdash; 等,怕对收索有影响,就把他转换为--,这在php中有一个自带的函数html_entity_decode(),它可以将实体转换为字符。

html_entity_decode() 是htmlentities() 的反函数。 

语法

html_entity_decode(string,quotestyle,character-set)

 参数  描述
 string  必需。规定要解码的字符串。
 quotestyle  

可选。规定如何解码单引号和双引号。

  • ENT_COMPAT - 默认。仅解码双引号。
  • ENT_QUOTES - 解码双引号和单引号。
  • ENT_NOQUOTES - 不解码任何引号。
 character-set  

可选。字符串值,规定要使用的字符集。

  • 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 - 日语
posted @ 2016-12-25 20:26  天涯海角路  阅读(1304)  评论(0)    收藏  举报