PHP short open tag vs long open tag
Possible Duplicate:
Are PHP short tags acceptable to use?
Which is better to use, or considered better practice: <?php or <? . I've always wanted to know. Or is it more of a preference for the programmer.
<?php is the official standard. I've never encountered a problem where a browser was confused, but just using <? can also declare XML and might not be the best habit to form.
I'll tell you this though - other programmers will always appreciate the standard. I would go with <?php for sure.
<?php - always, definitely.
Several reasons; the biggest being "disambiguates PHP from SGML (eg XML)".
As of PHP 5.4, <?= will be available regardless of the short_open_tags ini parameter, so if you're forward-looking you could get away with using <?= inside HTML, in place of <?php echo , however for non-echos always use <?php as <? still depends on the ini.
That said, many hosts have only recently adopted 5.3, and 5.4 is only in beta so if this is a library or something that might reach other's servers soon, I'd stick with <?php for both.
上一篇: 我如何将PHP短标签转换为完整的标签
下一篇: PHP短打开标签与长打开标签
