In the laravel framework we can use blade to add PHP code in html file.
We are using both {{ }}
and {!! !!}
syntax in blade files of Laravel.
What is the difference between them?
By default, Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax: Hello, {!! $name !!}. Follow this answer to receive notifications.
Basically its know as Scope resolution operator (::) Simply it is token which allow access to static, constant and overridden properties of method of a class. Example- in laravel we call model like this.
Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.
Two of the primary benefits of using Blade are template inheritance and sections. We can define a blade page as a combination of layout and sections. Since most of the general web applications will have the same layout across the web pages.
Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.
If you pass data from your Controller to a View with some HTML styling like:
$first = "<b>Narendra Sisodia</b>";
And it is accessed, within Blade, with {{ $first }}
then the output'll be:
<b>Narendra Sisodia</b>
But if it is accessed with {!! $first !!}
then the output'll be:
Narendra Sisodia
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With