0

For printing any PHP variable the following syntax is used sometimes

<?= $x ?>

Can anyone please explain when should I use this instead of

<?php echo $x; ?>

and what the name of that operator <?= ?

Any help is appreciated.

Devasish
  • 1,917
  • 2
  • 22
  • 32

2 Answers2

0

It's a "short tag"; this one is an abbreviation for "<?php echo". You need to be careful when using it or any other short tags as not all servers are configured to render them correctly.

A bit more info can be found here: http://php.net/manual/en/language.basic-syntax.phptags.php

jackel414
  • 1,636
  • 2
  • 13
  • 29
0

it's fast echo. You can use it with html. <div class="<?=$your_class"></div>

Vlad Mazur
  • 64
  • 1
  • 6