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

php – 如何将字符转换为HTML字符?

发布时间:2020-12-13 22:18:56 所属栏目:PHP教程 来源:网络整理
导读:lt;?php echo“Hello World
& lt;?php echo“Hello World!”; ?&安培; GT;

应该:

<?php echo“Hello World!”; ?> 我如何在PHP中执行此操作?

解决方法

你需要其中一个:

html_entity_decode()
htmlspecialchars_decode()

> html_entity_decode() in PHP Manual
> htmlspecialchars_decode() in PHP Manual

主要区别在于html_entity_decode()将翻译字符串中的所有HTML实体(& lt;变为<,& aacute;变成á等),而html_specialchars_decode()仅翻译一些特殊的HTML实体:

The converted entities are: &amp;,&quot; (when ENT_NOQUOTES is not
set),&#039; (when ENT_QUOTES is set),&lt; and &gt;.

(编辑:李大同)

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

    推荐文章
      热点阅读