'ErrorException Undefined variable: test (View: F:\mca\SEM2\laravel\Example-app\resources\views\home.blade.php)

**public function show(){
    $test = "Test Views";
    return view('home',$test);
}**

in home.blade.php

{{$test}}

Error Exception : $test is undefined

how can i fix it ?



Solution 1:[1]

Your public function is being declared outside a class.

This code seems to work:

function show(){
  $test = "Test Views";
  return view('home',$test);
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mint