加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php自定义函数转换html标签示例

发布时间:2020-12-12 21:44:59 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解php自定义函数转换html标签的方法。供大家参考研究具体如下: dog now";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a; // I'll quot;walkquot; the lt;bgt;doglt;/bgt; nowecho $b; // I'll "walk" the dog now// F

本篇章节讲解php自定义函数转换html标签的方法。分享给大家供大家参考,具体如下:

dog now"; $a = htmlentities($orig); $b = html_entity_decode($a); echo $a; // I'll "walk" the <b>dog</b> now echo $b; // I'll "walk" the dog now // For users prior to PHP 4.3.0 you may do this: function unhtmlentities($string) { // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei','chr(hexdec("1"))',$string); $string = preg_replace('~&#([0-9]+);~e','chr("1")',$string); // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string,$trans_tbl); } $c = unhtmlentities($a); echo $c; // I'll "walk" the dog now ?>

运行结果如下图所示:

更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、及《》

希望本文所述对大家PHP程序设计有所帮助。

(编辑:李大同)

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

    推荐文章
      热点阅读