先来看一个实例:
$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原始字符
<p>是HTML实体,因为校园号<的实体是< 大于号的实体>的实体为>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。