Isaac Bennetch on 30 Mar 2007 14:38:37 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] PHP short tags

  • From: "Isaac Bennetch" <bennetch@gmail.com>
  • To: "Philadelphia Linux User's Group Discussion List" <plug@lists.phillylinux.org>
  • Subject: [PLUG] PHP short tags
  • Date: Fri, 30 Mar 2007 10:38:28 -0400
  • Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=LuiybYnQBqu/wFyv1tnG2W4gD1wxA4z3fP5Lt5mVYTEz1Oe/848NVmPlYvcJvWZaZqMimlnay5iVc3HLptwfQZhZJUZY/ySIqMSaHHNU7ehVlQMjiKYITGKaeQxSpH7xaVw0HoPxU1QEu863nwddmAg6hl+tyEBjU3ualj93VSI=
  • Reply-to: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
  • Sender: plug-bounces@lists.phillylinux.org

Okay, since I've run in to this before I figured I should clear the
air regarding which is acceptable: <? or <?php

PHP calls this "short_open_tag" and it's configurable in php.ini
(elsewhere too, but we won't get in to that). For a long time everyone
had them enabled and used <? to open their scripts. Then people
realized that it conflicts with XML's <?xml ?> inline tags, so more
hosts started switching to setting short_open_tag to 0, forcing the
full open tag, <?php -- incidentally this also affects the short echo,
<?=... in place of <?php echo...

So as long as your server is configured for short open tags, you're
okay, but most people I've heard from think one should use the long
form "just in case" the code is deployed on a server where short tags
are disabled or in case the option removed from PHP in the future.

You can read essentially what I wrote above on the PHP site here:
http://us3.php.net/ini.core. Incidentally, if you miss Microsoft, you
can pretend you're coding in ASP by enabling asp_tags and using <%
instead of <?. Determining why one would want to do that is left as an
exercise to the reader.

Hope this helps,
~isaac
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug