gpt4 book ai didi

php - 带有未转义 html 的 Laravel laravelcollective/html textarea

转载 作者:行者123 更新时间:2023-12-01 22:58:31 25 4
gpt4 key购买 nike

我有一个用 laravelcollective/html 表单包制作的表单。现在我想在文本区域中输入未转义的 HTML 标记:

<p>This is HTML-Markup text</p>

我的表格是这样的:

{!! Form::label('body', 'Body:') !!}
{!! Form::textarea('body' , null , ['class' => 'form-control']) !!}

我用 {{ }} 试过了但它仍然会转义文本区域中的 HTML。

另外:有没有办法限制允许的 HTML 标记(可能使用 regex)?例如。只有<p>, <h1> and <div>没有 <script> .

我正在使用 Laravel 5.2。

谢谢大家。

最佳答案

试试这个{{!! !!}} 用于显示结果文本区域

By default, Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:

{!! $str!!}

关于php - 带有未转义 html 的 Laravel laravelcollective/html textarea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35147669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com