为了账号安全,请及时绑定邮箱和手机立即绑定

如图,请问PHP html_entity_decode()要如何转换字符?

如图,请问PHP html_entity_decode()要如何转换字符?

PHP
HUX布斯 2022-03-03 07:07:17
$db->Execute();$sql="select body from dede_addonarticle where aid='$aid'";$result=mysql_query($sql);$row=mysql_fetch_array($result);$b=$row['body'];echo html_entity_decode(htmlentities("$b"));//这句要如何写,如何把数据库中body的HTML转换字符前端调用。输出像下面图中的格式这样。把body内容包含在{"body":"数据body内容”}
查看完整描述

1 回答

?
牧羊人nacy

TA贡献1862条经验 获得超7个赞

方法/步骤

1
htmlspecialchars()转义特别的字符为HTML实体;
'&' (ampersand) becomes '&' '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. ''' (single quote) becomes ''' only when ENT_QUOTES is set. '<' (less than) becomes '<' '>' (greater than) becomes '>'
2
htmlspecialchars_decode()将实体转成HTML代码,函数1的反函数。
3
htmlentities()
这个是全部转换html实体,和htmlspecialchars()区别在于,这个函数是转义全部的字符,而htmlspecialchars()仅仅转义上面限定的5个特殊字符!
html_entity_decode() 函数
把 HTML 实体转换为字符。

查看完整回答
反对 回复 2022-03-07
  • 1 回答
  • 0 关注
  • 119 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信