Laravel 5.3刀片解码HTML特殊字符

Md.*_*hid 5 laravel

我在我的数据库中保存了一些HTML代码.当我将数据传输到刀片服务器时,CSS无法正常工作.

在页面源代码中,我发现<显示为'<'

我用什么方法将<转换为<

有人帮我吗?

小智 11

将语法更改{{ }}{!! !!}应该可以解决的问题


Rim*_*han 6

尝试这个: html_entity_decode()

{!! html_entity_decode($string, ENT_QUOTES, 'UTF-8') !!} 
Run Code Online (Sandbox Code Playgroud)


Lah*_*hah 5

{!! html_entity_decode(nl2br(e($text))) !!}
Run Code Online (Sandbox Code Playgroud)
  • e函数运行htmlentities给定的字符串。
  • nl2br在字符串中的所有换行符之前插入 HTML 换行符
  • html_entity_decode将所有 HTML 实体转换为其适用的字符

nl2br(e($text)){!! !!}不足以转换&quot;为“

我使用过html_entity_decode,然后它就完全按照我想要的方式工作了。我仍然认为对于一件简单的事情来说太多了。