Search code examples
phphtmllaravellaravel-5.3

PHP what is the difference between { } and {{ }}


I'm using PHP Laravel framework and I came to some code examples where {{ }} is use inside a html code, like this:

<link rel="stylesheet" href=" {{ URL::to('css/app.css') }} ">

My conclusion is that the {{ }} are used to write no-HTML code inside the HTML, is that correct?

And for what is the { } used?

Thanks for your answer.


Solution

  • There is no { } in Blade, {{ }} displays escaped data and {!! !!} displays unescaped data.

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

    https://laravel.com/docs/5.3/blade#displaying-data