Reputation: 99
I tried to show a variable this way on a blade template on laravel
<input type="text" name="win-phone" class="modal-input" value="{{ $info['fields']['phone'] }}">
and it doesn't work , but this way
<input type="text" name="win-phone" class="modal-input" value="{!! $info['fields']['phone'] !!}">
It worked, why? the first way its no the correct wat?
Upvotes: 2
Views: 3629
Reputation: 1047
By default, Blade {{ }}
statements are automatically sent through PHP
's htmlspecialchars
function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:
Hello, {!! $name !!}.
In summary, if used in this way disabled HTML is allowed.
Source : https://laravel.com/docs/7.x/blade
Upvotes: 5
Reputation: 1513
There are two way to print your php
variable in blade
template.
1. Statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attack
{{ $your_variable }}
2. If you do not want your data to be escaped, you may use the following syntax
{!! $your_variable !!}
Upvotes: 0