先来看一个实例:
<?php
$string = \" " Learn Everything on tutorialsplane.com it\'s easy!!! "\";
echo $string.\"<br/>\";
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!!! "<br/>\" 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标签<p>来说明:
- <p>标签就是HTML原始字符
- <p>是HTML实体,因为校园号<的实体是< 大于号的实体>的实体为>
继续阅读与本文标签相同的文章
-
中国客车“抢眼”世界客车博览会
2026-05-14栏目: 教程
-
充分利用系统磁盘空间,Windows 7操作系统如何创建压缩文件夹
2026-05-14栏目: 教程
-
iPhone11系列性能测试:碾压华为麒麟990,性能超越它两倍!
2026-05-14栏目: 教程
-
手机导航是怎样判断路况的?不仅是通过卫星,这几个原因使导航更智能
2026-05-14栏目: 教程
-
手机信号突然从“4G”变成“E”,是什么意思?客服给出答案
2026-05-14栏目: 教程
