Difference between using { ! ! } and @php tags

Hi all,

Sage newbie here. Probably a silly question, I know that double curly braces in blade echoes and escapes the content, but is there any practical difference between using {!! !!} and simply using @php @endphp tags if what I’m wrapping, say a wp related function, already echoes the content?

Since {!! !!} also echos content (unescaped) then using it to echo a function that already echos on its own is likely to produce an unexpected result. A best practice would be to use a WordPress function that does NOT echo by default, or to use output buffering in a controller if absolutely necessary.

Otherwise, if a function that echos is the only option, @php is a better solution.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.