Home >Backend Development >PHP Tutorial >What is the difference between {{}} and {!! !!} in Laravel?
The difference between "{{}}" and "{!! !!}" in Laravel: "{{}}" supports escaping, and a piece of html code is just output as an ordinary string; "{ !! !!}" does not support escaping, and a piece of html code can be parsed normally.
##The difference between {{}} and {!! !!} in Laravel
{{}} Supports escaping, a piece of html code is just output as an ordinary string; {!! !!} does not support escaping, and a piece of html code can be parsed normally.
Route::get('/demo', ['uses' => $namespacePrefix . 'BusinessController@demo', 'as' => 'demo']);Controller
public function demo() { $address = "<span style='color:deeppink'>我的家在哪遥远的北方</span>"; return view('business.demo')->with(['name' => '我叫张三', 'sex' => '我的性别男', 'address' => $address, ]); }View layer code
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>向视图传递值</title> </head> <body> {!!$name.$sex. $address !!}-->不支持转义<br> {{$name.$sex. $address}}-->支持转义(我理解未转换原来的意义) </body> </html>Display results As follows
For more related knowledge, please visit PHP Chinese website! !
The above is the detailed content of What is the difference between {{}} and {!! !!} in Laravel?. For more information, please follow other related articles on the PHP Chinese website!