I'm trying to pass a variable to a view so that I can have it as a global variable in a function, but it's not working. I'm not getting any output from the function, but I'm also not getting an error message. Where am I going wrong?
web.php
<?php
Route::get('/', function() {
$abc = 'abc';
return view('front')->with(['abc'=>$abc]);
});
?>
front.blade.php
<?php
function fn() {
global $abc;
return $abc;
}
?>
{{ fn() }}