(一)给模板分配数据
(1)在控制器中给模板分配数据
return view('firstclass.index',['name'=>'Alice','number'=>123]);
在模板中获取数据时需要两层{{$name}}
(2)使用return view('firstclass.index')->with('name','Jerry')->with('password','123456');
注意:在模板中注释代码时使用html注释,上一次的变量将会无法无法注释,需要在变量两侧加上--
eg:{{--$name--}}
(3)使用 $str1='welcome';
$str2="Alice";
return view('firstclass.index',compact('str1','str2'));