LARAVEL

Laravel blade Displaying variables


In Laravel's Blade templating engine, you can display variables using the {{ }} syntax. Here's how you can display variables in a Blade template:

 

This Way to Displaying variables in laravel blade Template

<!-- Displaying a variable -->
{{ $variable }}

<!-- Displaying an array element -->
{{ $array['key'] }}

<!-- Displaying an object property -->
{{ $object->property }}

<!-- Displaying a variable with HTML escaping -->
{!! $htmlVariable !!}

Variables are usually passed to Blade templates from controllers or views. For example, if you have a controller method like this:

public function show()
{
    $variable = 'Hello, world!';
    return view('example', compact('variable'));
}

You can then access $variable in your Blade template named example.blade.php like so:

<p>{{ $variable }}</p>

 


LARAVEL