PHP short open tag versus long open tag

Possible duplicate:
Are short tags valid for PHP?

This is better used or considered best practice: <?php or <? . I always wanted to know. Or is it rather a preference for the programmer.

+4
source share
4 answers

<?php is the official standard. I never encountered a problem when the browser was confused, but just using <? can also declare XML and may not be the best habit to form.

I will tell you this, although other programmers will always appreciate the standard. I would go with <?php sure.

+10
source

<?php - always, definitely.

A few reasons; the largest of them is "disambiguating PHP from SGML (like XML)."

+3
source

As with PHP 5.4, <?= Will be available regardless of the short_open_tags ini parameter, so if you look at the forecast, you can avoid using <?= Inside HTML instead of <?php echo , however for non-echo always use <?php since <? still dependent on ini.

However, many hosts only recently adopted 5.3, and 5.4 - only in beta, so if it is a library or something that may appear on other servers soon, I would stick with <?php for both.

+3
source

I can recommend <?= ;?> In the HTML code. But, I will recommend <?php whenever, because this is a standard and less confusing XML with an example.

0
source

Source: https://habr.com/ru/post/1379583/


All Articles