home.php //controller
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class home extends Controller
{
public function index($home)
{
return view('home',['home'=>$home]);
}
}
web.php
Route::get('home/{home}',[home::class,'index']);
home.blade.php
{{home}}
ErrorException
Use of undefined constant home – assumed ‘home’ (this will throw an Error in a future version of PHP) (View: C:UsersRASHEED1612Eprojectresourcesviewshome.blade.php)
3
Answers
You cannot call ‘home’ directly in blade file.
You should replace
'home.blade.php' {{home}}
into
'home.blade.php' {{$home}}
Try it.
If you want to print a variable in laravel that’s how you do it:
In your home.blade.php change
{{home}}
to{{$home}}
and it will work.