Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ibanks's avatar

Difference Between Double Braces and PHP Tags

Hello. So I've discovered something and needed to know the difference. When I have this:

{{ $msg = $errors->get('errormsg') }}

php throws a syntax error.

But when I have this:

<?php $msg = $errors->get('errormsg') ?>

The statement is evaluated and the assignment is made. What is the difference between the two?

0 likes
3 replies
tykus's avatar

Double braces translate to <?php echo $thing; ?>

BrandonSurowiec's avatar

Use {{ $var }} to echo variables. It gets translated to <?php echo e($var); ?>.

{!! $var !!} is <?php echo $var; ?>.

Please or to participate in this conversation.