I just installed laravel 5.3, set a template variable, and displayed it in the template, but it doesn't work. The code is as follows:
routing
Route::get('/', function () {
return view('index',['msg'=>'hello world']);
});
template
{{ $msg }}
Web page effect
Question
Where is the problem? I followed the documentation, but it just doesn’t work. But using native PHP code in the template works: <?php echo $msg; ?>
It seems like your template file is not parsed using the Blade engine.
Are you sure your template file has
.blade.php
as the extension?