Jump to content


<?php or <?

  • Please log in to reply
6 replies to this topic

#1 AndrewRy

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 15 July 2006 - 08:31 PM


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?

#2 Chevy

  • Members
  • PipPipPip
  • Advanced Member
  • 163 posts

Posted 15 July 2006 - 08:33 PM

I think <? is better, thats what I always use

#3 akitchin

  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 08:39 PM

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.

#4 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 15 July 2006 - 09:18 PM

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.


#5 hostfreak

  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 16 July 2006 - 12:35 AM

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 .

#6 willfitch

  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts
  • LocationNew Hope, PA

Posted 16 July 2006 - 03:51 AM


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.
Zend Certified Engineer (ZEND001989)

#7 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 16 July 2006 - 10:30 AM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users