<?php
can always be used. <?
can only be used if the short_open_tag directive is turned on.
short_open_tag tells PHP whether the short form (<? ?>
) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?>
inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>
. Also, if disabled, you must use the long form of the PHP open tag (<?php ?>
).
Note: This directive also affects the shorthand <?=
, which is identical to <? echo
. Use of this shortcut requires short_open_tag to be on.
-- Description of core php.ini directives
As others have mentioned, this directive is often turned off so for portability reasons I prefer using <?php ?>
. If this is not an issue, there shouldn't be much difference other than that if the directive is turned on you can also use the <?=
shorthand thingy.