使用Laravel在注释系统中显示换行符

问题描述 投票:0回答:1

我正在使用Laravel进行评论系统构建。一切正常,除了在从数据库中提取注释后剥离注释换行符,从而将注释显示为单个字符串。如何在不影响应用程序安全性的情况下以输入方式显示用户内容..?

<div class="comments">
   <h3 class="comments-title"><span class="glyphicon glyphicon-comment"></span> {{ $post->comments()->count()}} Comments</h3>
   @foreach($post->comments as $comment)
   <div class="comment-content col-md-12">
      {{ $comment->comment }}
   </div>
</div>
   @endforeach
</div>
security laravel-5.4 form-helpers
1个回答
0
投票

nl2br - 在字符串中的所有换行符之前插入HTML换行符。

{{ nl2br($comment->comment) }}

http://php.net/manual/en/function.nl2br.php

© www.soinside.com 2019 - 2024. All rights reserved.