【问题标题】:Decoding HTML tags in Laravel 5在 Laravel 5 中解码 HTML 标签
【发布时间】:2016-02-12 02:15:00
【问题描述】:

我正在为我的 Laravel 5.1 自定义 CMS 使用 CKeditor。当我在我的视图中请求数据库中存储页面的内容时,它们会出现带有<p>Hello world</p> 之类的 HTML 标记。 我已经使用html_entity_decode() 有和没有指定的字符集无济于事。 还值得一提的是,在我看来,我使用的是 Blade 模板引擎。因此,我的演示代码看起来像

$post->content = '<p>Hello world</p>'; // from the database from controller
{{html_entity_decode($post->content)}} //did not decode

我也尝试在我的控制器中使用它,但它没有改变任何类似的东西

$post->content = html_entity_decode($post->content); //before sending it to the view

我需要你的帮助来解决这个问题。

【问题讨论】:

    标签: html laravel-5 ckeditor decoding


    【解决方案1】:

    而不是{{html_entity_decode($post-&gt;content)}}, 试试这个:

    {!! $post->content !!}
    

    更多信息在这里https://laravel-news.com/2014/09/laravel-5-0-blade-changes/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      • 2011-05-18
      • 2015-12-27
      • 2018-11-10
      • 2017-04-27
      • 1970-01-01
      • 2019-08-06
      相关资源
      最近更新 更多