-1

I know the syntax for <? ?> is not always allowed, and will spark notices if you have them enabled... but I haven't seen many people use <?=$var?> to echo a variable... is this illegal syntax or completely accepted in all versions of PHP?

<?php echo $var; ?>

vs

<?=$var?>
Arian Faurtosh
  • 17,987
  • 21
  • 77
  • 115

2 Answers2

0

Yes, it depends on your php.ini settings. short_open_tag has to be On.

Your code will not work, if short open tags aren't allowed (old servers [< PHP 5.4.0] often don't support it by default). If you'd like to write your code downwards compatible, do not use it.

I got a lot of anoying trouble because of being lazy and using short open tags. ;-)

Mr. B.
  • 8,041
  • 14
  • 67
  • 117
0

Before PHP 5.4.0, this syntax required the short_open_tag flag to be enabled. Since 5.4.0, it's always usable.

Jon Newmuis
  • 25,722
  • 2
  • 45
  • 57