加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php htmlentities() 和html_entity_decode()函数使用分析

发布时间:2020-05-25 01:50:51 所属栏目:PHP 来源:互联网
导读:php htmlentities函数将html字符转换为HTML实体,那么将html实体转换为html字符就使用html_entity_decode函数,本文章向大家介绍htmlentities() 和html_entity_decode()函数使用方法和基本使用实例,需要的朋友可以参考一下。

其实小编在发表这篇文章之前对htmlentities() 和html_entity_decode()函数也没有过多的研究,每次使用到这两个函数时就去查看手册,但今天小编对这两个函数仔细研究了一下,给大家分享一下我对这两个函数的理解。

htmlentities() 和html_entity_decode()是一对逆函数,htmlentities负责将html字符转换为HTML实体,而html_entity_decode负责将HTML实体转化为html字符:

$str="what's this";

$en_str=htmlentities($str,ENT_QUOTES);

echo $en_str."
";

echo html_entity_decode($en_str,ENT_QUOTES);

?>

运行后浏览器输出如下:

what's this

what's this

查看页面源码,结果如下:

what's this
what's this

可以看出html_entity_decode函数将被htmlentities处理过的字符串还原了。

(编辑:安卓应用网)

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

    推荐文章
      热点阅读