blade常用语法
<?php namespace App\Http\Controllers; use http\Env\Request; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; public function index($count){ $json = ['name'=>'小辉','age'=>20]; return view('welcome',['html'=>'<p>hello</p>','json'=>$json,'count'=>$count]); } }
视图层中测试语法
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- Fonts -->
</head>
<body>
{!! $html !!}
'{@json($json)}'
@if($count==1)
等于一
@else
不等于一
@endif
@unless($count==1)
这个数不等于1
@endunless
@isset($count)
$count有定义
@endisset
@empty($count)
$count等于空
@endempty
</body>
</html>
每天坚持,终会抵达!

浙公网安备 33010602011771号