Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `{{ }}` and `{!! !!}` when using forms?

Tags:

forms

laravel

I'm learning Laravel but I am confused. When using forms, what is the difference between using exclamation marks vs another curly bracket? Both seem to accomplish the same thing.

{!! Form::open(array('route' => 'post_store', 'class' => 'form')) !!}

{{ Form::open(array('route' => 'post_store', 'class' => 'form')) }}

like image 454
Taylor Swift Avatar asked Sep 11 '25 22:09

Taylor Swift


1 Answers

{!! !!} will prevent to escape your data.

By default, Blade {{ }} statements are automatically sent through PHP's htmlspecialchars() function to prevent XSS attacks.

A questionable use for this would be, for example, injecting HTML fragments to make links clickable when the browser renders the templates' output, compare Displaying Unescaped Data (Laravel Blade).

So if $data = "<a href=https://example.net>click me</a>;, for example,

{{ $data }} is not clickable.

{!! $data !!} will be clickable.

like image 53
Felix Maxime Avatar answered Sep 14 '25 13:09

Felix Maxime