0
votes

I am curious between the difference between {!! !!} and {{ }}

In laravel, Model-View-Controller it is used in View where the user declare the variables which was sent from the Controller

Example Given:

**In Controller**

public function show(){
     $somevariable = 'What is the difference';
     return view('someView.page')->with('somevariable', $somevariable)
}



**In View**

<span class="label label-default">{!! $somevariable !!}</span>

<span class="label label-default">{{ $somevariable }}</span>

Both works but I wanna know if there's significant changes it does and what is their differences.

1

1 Answers

3
votes

See the docs:

Blade {{ $name }} 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: {!! $name !!}

Be very careful when echoing content that is supplied by users of your application. Always use the escaped, double curly brace syntax to prevent XSS attacks when displaying user supplied data.