我在网上的某处读到,在 blade
模板引擎中,{{ }}
会自动清理输出。
但是,如果我想从 Controller echo
一个经过清理的Input::get
怎么办。最好的方法是什么(e()
只是一个 htmlentities
或 HTML::entities
或其他东西)?
最佳答案
I have read somewhere on the web that in the blade template engine, the {{ }} automatically sanitize output.
这是不正确的。您需要使用三 (3) 个大括号来清理输出 {{{ }}}
But, what if I want to echo a sanitized Input::get from the controller.
你不应该从你的 Controller 中输出——你应该从 View 中输出
What is the best way to do it (e() which is just an htmlentities or HTML::entities or something else)?
是的 - e()
是 Laravel 4 中最好的实现方式。
在后端,{{{ }}}
所做的一切实际上都变成了 {{ e() }}
的等价物
编辑:在 Laravel 5 中,{{ }}
和 {{{ }}}
现在都会清理输出。如果你需要在 Laravel 5 中有未处理的输出——你可以使用 {!! !!
关于php - laravel 4 - 清理 Input::get() (e() vs HTML::laravel 4 中的实体),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18534158/