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?

5 Answers 11

If you don't want the data to be escaped then use {!! !!} else use {{ }}.

from the documentation: https://laravel.com/docs/5.1/blade

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 !!}.

Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.

You can see more here:https://laravel.com/docs/master/blade

up vote 42 down vote accepted

Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.

If you pass data from your controller to view with some styling like as

$first = "<b>Narendra Sisodia</b>";

and if it is accessed within blade with {{ $first }}

then the output'll be

<b>Narendra Sisodia</b>

and if it is accessed within blade with {!! $first !!}

then the output'll be

Narendra Sisodia

To escape data use

{{ $data }}

If you don't want the data to be escaped use below

{!! $data !!}

Not the answer you're looking for? Browse other questions tagged or ask your own question.