blade常用语法
Posted jichenghui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了blade常用语法相关的知识,希望对你有一定的参考价值。
<?php namespace AppHttpControllers; use httpEnvRequest; use IlluminateFoundationAuthAccessAuthorizesRequests; use IlluminateFoundationBusDispatchesJobs; use IlluminateFoundationValidationValidatesRequests; use IlluminateRoutingController 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>
以上是关于blade常用语法的主要内容,如果未能解决你的问题,请参考以下文章