...

View Full Version : <? or <?PHP



kenwvs
08-21-2006, 08:17 PM
Am I correct in my thoughts that I had read somewhere that <? will only work in later versions, or maybe if Global is turned on?

Someone told me that they work the same and it doesn't make any difference which one you use, but I am finding that the <? won't work on my version.

Any comments on where I may have read about this?

Ken

oracleguy
08-21-2006, 08:27 PM
Well depending on the PHP settings as well, <? might not work. I forget what the option is called but I know I had to enable it on the last apache web server I setup a couple weeks ago.

Brandoe85
08-21-2006, 08:27 PM
Short tags is what you're looking for.
http://ca.php.net/manual/en/ini.core.php#ini.short-open-tag

GJay
08-21-2006, 08:29 PM
<? works with any version of PHP worth considering, but it's possible to turn off support in the php settings, the 'short tags' option or something similar, therefore if you want code that you know will work regardless of local settings, avoid the use of <? and <?= and stick to <?php.
If that's not going to be an issue for you, then use whichever you prefer, I personally use <?= (to echo a variable) in the middle of html, as I think it's neater, but some would disagree.
(if you're not familiar with <?=, then the two lines below are the same:


<a href="http://www.example.com/<?php echo $pagename;?>">Click!</a>
//and
<a href="http://www.example.com/<?=$pagename?>">Click!</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum