Home  >  Article  >  PHP Framework  >  Detailed explanation of the difference between {{}} and {!! !!} in laravel

Detailed explanation of the difference between {{}} and {!! !!} in laravel

angryTom
angryTomforward
2020-02-19 17:57:475276browse

This article introduces the difference between {{}} and {!! !!} in laravel. Interested friends can refer to it.

Detailed explanation of the difference between {{}} and {!! !!} in laravel

##Detailed explanation of the difference between {{}} and {!! !!} in laravel

1 {{}} in .{{}} and {!! !!} supports escaping. A piece of html code is just output as an ordinary string. {!! !!} does not support escaping. A piece of html code can be parsed normally.

1.2 What does it mean specifically? Let’s show the code

2. Routing

Route::get('demo','DemoController@demo');

3 .Controller

<?php
namespace App\Http\Controllers;use Illuminate\Http\Request;class DemoController extends Controller
{    //    public function demo(){        $address="<span style=&#39;color:deeppink&#39;>我的家在哪遥远的北方</span>";        return view(&#39;demo&#39;)->with([            &#39;name&#39;=>&#39;我叫张三&#39;,
            &#39;sex&#39;=>&#39;我的性别男&#39;,
            &#39;address&#39;=>$address,
            ]);
    }
}

4.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><br><br><br>{{$name.$sex. $address}}-->支持转义(我理解未转换原来的意义)</body>
</html>

5.The display result is as follows

For more technical articles related to the laravel framework, please visit the

laravel tutorial column!

The above is the detailed content of Detailed explanation of the difference between {{}} and {!! !!} in laravel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete