Jump to content

Archived

This topic is now archived and is closed to further replies.

AndrewRy

<?php or <?

Recommended Posts

Hello,

I am starting to get more into PHP coding even though I have been using it for several months now. My question is which delimiter is better to use:

<?php or <?

Is it just general preference or is there one that can be better in some ways than the other depending on PHP version and server?

Share this post


Link to post
Share on other sites
it's merely preference.  it's better to be in the habit of using <?php, as this will always work.  <? will only work when the setting in php.ini (i think it's something like allow_shorttags) is enabled; otherwise, you'd have to go back and change all those tags if you end up on a host that doesn't enable the setting.

Share this post


Link to post
Share on other sites
It has been rumored that the use of short tags "<?" and "<?=" will be going away in PHP6. The problem is that the start tag for XML also starts with a "<?". So just allowing the short tags can be confusing.

Ken

Share this post


Link to post
Share on other sites
It depends. As of now, the standard tag <?php ?> and the script tag
<script language="php"></script> will always work. The short tag <? ?> will only work if short_open_tag is switched to "on" in php.ini .

Share this post


Link to post
Share on other sites
Actually,

You can run into issues with short tags (<? ).  If you are trying to use XML with PHP, XML will require the opener (<?xml), and allowing short tags will confuse the interpreter.

Share this post


Link to post
Share on other sites
I would agree it is down to personal preference. I prefer <?php as then I know my script will run in any enviroment. Also <?, <?= and <script language="php"></script> will be gone as of PHP6.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.