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.
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.
As of PHP 5.4,
<?=
will be available regardless of theshort_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.I may recommend
<?= ;?>
in HTML code. But, I will alawys recommend<?php
whenever because it's standard and less confusion with XML by example.<?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 (e.g. XML)".