Laravel 9 | Displaying Data | Assign Default Value in Blade Template | Use Functions in Blade Template
Displaying Data
Core PHP Syntax Vs Blade Template Syntax
1. Core PHP Syntax:
2. Blade Template Syntax:
Result is given below
This is basic code to pass values from routes>web.php
This is a main heading
";
$data = compact('content');
return view('home')->with($data);
});
Assign Default Value in Blade Template
If expected value not found then assign default value as given
code path resources>views>home.blade.php
Welcome , {{ $name ?? "Guest" }}
Basic route code is given below
code path routes>web.php
When value passed in url
When value is not passed in url it will show the default
Use Functions in Blade Template
Set routecode path routes>web.php
Time , {{ time() }}
Time , {{ date('d-m-y') }}
Comments
Post a Comment