2

By one hand, I know the use of the Short Open Tag <? in PHP is discouraged for several reasons: only available if enabled in php.ini, for clarity and avoiding confusions...

By the other hand, I see that from PHP 5.4.0 and above, <?= is always available regardless of the short_open_tag ini setting.

More about PHP tags here.

My question: Is <?= considered Short Open Tag? Should I avoid using it in my PHP coding? Or should I do the opposite and use it since is very useful and not affected by the 'discourage recomendation'?

Edited for clarifying: <?= ... ?> is equivalent to <?php echo ... ?>

MarcM
  • 2,173
  • 22
  • 32
  • Excuse me if I am missing something, but what benefit would = hold over – Jethro Hazelhurst Feb 14 '17 at 11:34
  • Personally i'd follow the best practice route and stick with ``. I can't really dispute it as everybody has their own opinion but mines habit more so and classed as best practice. – Option Feb 14 '17 at 11:34
  • Possible duplicate of [Are PHP short tags acceptable to use?](http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use) – Option Feb 14 '17 at 11:35
  • 6
    @Jethro Hazelhurst `= ... ?>` is equivalent to ``, not to `` – MarcM Feb 14 '17 at 11:36
  • Hmm, interesting! – Jethro Hazelhurst Feb 14 '17 at 11:38
  • 3
    `=` is no longer considered a short open tag. The reason why `` was discouraged was (I think) because it was ambiguous under some situations. `=` doesn't have the same issue. I personally use it a lot. Others don't because they worry it will suffer the same fate as `` . I think until we see a deprecation notice it should be fine. – apokryfos Feb 14 '17 at 11:40
  • 1
    @apokryfos It was/is ambiguous to `` – Constantin Groß Feb 14 '17 at 11:44

1 Answers1

0

Since there is no formal answer, I put together some of the comments, which -in my opinion- actually answer the question:

<?= is no longer considered a short open tag. The reason why <? was discouraged was because it was ambiguous under some situations, i.e <?xml ... ?> or other markup languages.

MarcM
  • 2,173
  • 22
  • 32