What is the difference between {{ }} and {!! !!} in laravel blade files?({{ }} 和 {!! 有什么区别?!!} 在 laravel 刀片文件中?)
问题描述
在laravel框架中我们可以使用blade在html文件中添加PHP代码.
我们同时使用 {{ }} 和 {!!!!} Laravel 刀片文件中的语法.
它们有什么区别?
In the laravel framework we can use blade to add PHP code in html file.
We are using both {{ }} and {!! !!} syntax in blade files of Laravel.
What is the difference between them?
推荐答案
Blade {{ }} 语句通过 PHP 的 htmlentities 函数自动发送,以防止 XSS 攻击.
如果您将数据从控制器传递到具有一些 HTML 样式的视图,例如:
If you pass data from your Controller to a View with some HTML styling like:
$first = "<b>Narendra Sisodia</b>";
在 Blade 中使用 {{ $first }} 访问它,然后输出将是:
And it is accessed, within Blade, with {{ $first }} then the output'll be:
<b>Narendra Sisodia</b>
但是如果用{!!$first !!} 然后输出将是:
But if it is accessed with {!! $first !!} then the output'll be:
纳伦德拉·西索迪亚
这篇关于{{ }} 和 {!! 有什么区别?!!} 在 laravel 刀片文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:{{ }} 和 {!! 有什么区别?!!} 在 laravel 刀片文件中
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
