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

php html_entity_decode()实例解析

发布时间:2020-05-25 01:50:36 所属栏目:PHP 来源:互联网
导读:php html_entity_decode是htmlentities()的反函数,改函数用于将HTML实体还原为HTML字符,本文章将通过实例向大家解析php html_entity_decode()函数的使用方法。需要的朋友可以参考一下。

先来看一个实例:

$string = " " Learn Everything on tutorialsplane.com it's easy!!! "";

echo $string."
";

echo html_entity_decode($string);

?>

浏览器中输出结果:

" Learn Everything on tutorialsplane.com it's easy!!! "

" Learn Everything on tutorialsplane.com it's easy!!! "

查看页面源码:

" Learn Everything on tutorialsplane.com it's easy!!! "
" Learn Everything on tutorialsplane.com it's easy!!! "

可以看出没有使用html_entity_decode函数时,源代码里面显示的是html实体,使用html_entity_decode函数后,显示的是HTML字符串。

解析:

php html_entity_decode函数将HTML实体还原为HTML字符,该函数刚好与htmlentities()函数相反,htmlentities()函数是将html字符转换为HTML实体。

这里我要跟大家讲一样什么是HTML实体,什么是HTML原始字符。下面以HTML标签

来说明:

标签就是HTML原始字符

&lt;p&gt;是HTML实体,因为校园号<的实体是&lt; 大于号的实体>的实体为&gt;

(编辑:安卓应用网)

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

    推荐文章
      热点阅读