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?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If you don't want the data to be escaped then use
{!! !!}
else use{{ }}
.To escape data use
If you don't want the data to be escaped use below
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
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:If you pass data from your Controller to a View with some HTML styling like:
And it is accessed, within Blade, with
{{ $first }}
then the output'll be:But if it is accessed with
{!! $first !!}
then the output'll be:Narendra Sisodia