In the Foolowing scenario you will get the undefined variable error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
create a blade called sub.balde.php. create variable called $test sub.blade.php <?php $test='welcome to laravel training'; ?> create one more balde called main.php main.blade.php @include('sub') <?php echo $test; ?> |
in this case we will get the error as
ErrorException in c8b54f60da9fa9e08371cc15bab47dba58b6f7b3.php line 3: Undefined variable: test
Ans:solution for this error is as below
please assing the test varable as $this->test=’some text’;