i am new to larvel.I tried to pass the variable from controller toview but it did not worked. i am getting an error:
"Whoops, looks like something went wrong."
code used in controller:
public function showWelcome()
{
return View::make('hello', array('theLocation' => 'NYC'));
}
Code in hello.blade.php:
<h1 class="highlight">Blade has arrived in {{ $theLocation }} .</h1>
can you tell me is there any syntax error in the above code and is there any possibility of debugging the error??
Controller
return view('hello')->with(['theLocation' => 'NYC']);
View
<h1 class="highlight">Blade has arrived in {{ $theLocation }} .</h1>
There are many ways to pass data from Controller to View like:
return view('hello')->with(['key' => 'value']);
or
return view('hello', ['key' => 'value']);
And you can use it on view like:
<p>{{ $key }}</p>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.