第一种:
public function about(){
$name = "cai"
return view("sites.about")->with('name',$name);
}
public function about(){
return view("sites.about")->with([
'first' =>'jelly',
'last' =>'cai'
]);
}
第二种:
public function about(){
$data= [];
$data['first'] ='cai';
$data['last'] = 'muqing';
return view("sites.about",$data);
}
第三种:
public function about(){
$first = "cai";
$last = "muqing";
return view("sites.about",compact('first','last'));
}
视图接收:
<!DOCTYPT html>
<html>
<head>
<title>
laravist.com
</title>
<body>
<h1>
hello my laravel<?= $first,"",$last ?> 或者{{$first}} {{$;last}}或者 {!! first !!} {!! last !!}
</h1>
</body>
</head>
</html>