加入收藏 | 设为首页 | 会员中心 | 我要投稿 吉安站长网 (https://www.0796zz.com.cn/)- 科技、图像处理、媒体智能、办公协同、操作系统!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php html_entity_decode实例教程

发布时间:2022-07-29 10:54:39 所属栏目:PHP教程 来源:互联网
导读:关于html_entity_decode在大多数情况下是与htmlspecialchars htmlentities配合使用的. html_entity_decode用法: string html_entity_decode(string $string [,int $quote_style = ENT_COMPAT [, string $charset ]]). html_entity_decode() 函数把 HTML 实体
  关于html_entity_decode在大多数情况下是与htmlspecialchars htmlentities配合使用的.
 
  html_entity_decode用法:
 
  string html_entity_decode(string $string [,int $quote_style = ENT_COMPAT [, string $charset ]]).
 
  html_entity_decode() 函数把 HTML 实体转换为字符.
 
  html_entity_decode() 是 htmlentities() 的反函数也html_entity_decode() 是 htmlspecialchars() 的反函数.
 
  $str = "A 'quote' is bold www.phpfensi.com";
   
  Outputs: A 'quote' is <b>bold</b>
  $s = htmlspecialchars($str);
   
  echo $s;
   
  Outputs: A 'quote' is <b>boldwww.111cn.net</b>
   
  echo html_entity_decode($s);
   
  A 'quote' is bold
  再看一个实例,代码如下:
   
  $str = "John & 'Adams'";
  echo html_entity_decode($str);
  echo "";
  echo html_entity_decode($str, ENT_QUOTES);
  echo "";
  echo html_entity_decode($str, ENT_NOQUOTES);
  ?>//开源代码phpfensi.com
  //浏览器输出:
  John & 'Adams'
  John & 'Adams'
  John & 'Adams'
  如果在浏览器中查看源代码,会看到这些 HTML:
 
  <html>
  <body>
  John & 'Adams'<br />
  John & 'Adams'<br />
  John & 'Adams'
  body>
  html>
   

(编辑:吉安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读