1.{{}}和{!! !!} 中{{}}支持轉義 一段html代碼只是被當成普通的字符串輸出 ,{!! !!} 不支持轉移 一段html代碼可以被正常的解析
1.2具體什么意思呢我們上代碼演示
2.路由
Route::get('demo','DemoController@demo');
3.控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DemoController extends Controller
{
//
public function demo(){
$address="<span style='color:deeppink'>我的家在哪遙遠的北方</span>";
return view('demo')->with([
'name'=>'我叫張三',
'sex'=>'我的性別男',
'address'=>$address,
]);
}
}
4.視圖層代碼
<!doctype html>
<html lang="en">
<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.顯示結果如下
