I tried to pass a variable from Controller to View in Laravel with a simple variable, but It caused an error: Underfined variable.
I tried to change:
return view('home', $Test);
or
return view('home', 'Test' => $Test);
or
return view('home')->with('Test');
My Controller:
public function index(){
$Test = 55;
return view('home',compact('Test'));
}
My view
<html>
<body>
<h1> {{$Test}} </h1>
</body>
</html>
This is error:
ErrorException {#229 ▼
#message: "Undefined variable: Test"
#code: 0
#file: "E:\Desktop\aroundtrips\storage\framework\views\245291ca31ad79efeff6d548bc38081345e95242.php"
#line: 78
#severity: E_NOTICE
}