skip to Main Content

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


  1. You cannot call ‘home’ directly in blade file.
    You should replace
    'home.blade.php' {{home}}
    into
    'home.blade.php' {{$home}}
    Try it.

    Login or Signup to reply.
  2. If you want to print a variable in laravel that’s how you do it:

    <h1>{{ $home }}</h1>
    
    Login or Signup to reply.
  3. In your home.blade.php change {{home}} to {{$home}} and it will work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search