Home > Net >  What is this syntax " {!! " I found in a PHP file?
What is this syntax " {!! " I found in a PHP file?

Time:09-28

I recently started some research into Wordpress (beyond the basic stuff I've always done) and came across some code for a 'navwalker'. I'm looking into it and also the concept of a mega menu. It's early days just now but I came across the following syntax which stopped me in my tracks:

{!! $menu_navigation_left !!}

And to comment this code out

{{-- {!! $menu_navigation_left !!} --}}

I've not come across this before so I'm not sure if it's PHP or Wordpress specific. Or neither!? If anyone could shed some light on this syntax and what it is used for I'd be very grateful.

CodePudding user response:

This syntax is from Laravel Blade and it means display unescaped data.

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

https://laravel.com/docs/8.x/blade#displaying-unescaped-data

Beware of the security issues (XSS) when using this syntax.

As for the question you made in the comments, yes, you are probably going to find a $menu_navigation_left variable somewhere in the project.

  • Related