tallberg Posted January 6, 2007 Share Posted January 6, 2007 HiWhat is the differnce between using <? ...php stuff... ?> OR <?php ...php stuff... ?> I just down loaded some code using the first example and it does not appear to work on my wamp server?Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/ Share on other sites More sharing options...
ryld Posted January 6, 2007 Share Posted January 6, 2007 If I understand correctly, the difference is that shorthand PHP must be enabled on the server. If it's not working, you'll need to enable shorthand PHP.Because shorthand PHP is not used on all servers (evidenced by your shorthand not working), it is generally best (I would guess) to use[code]<?php ?>[/code]to enclose your PHP code blocks. Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154353 Share on other sites More sharing options...
genericnumber1 Posted January 6, 2007 Share Posted January 6, 2007 it's considered better "form" to use <?php also as ryld the shorthand tags also have to be enabled.In short use <?php 99% of the time :Dshamefully though, sometimes I use <?= DONT TELL ANYONE, our secret... I blame my laziness. Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154359 Share on other sites More sharing options...
ryld Posted January 6, 2007 Share Posted January 6, 2007 Just curious, but is it really that hard to type three letters?Also, IMO, shorthand never should have been invented. It just promotes bad habits, I think...If you KNOW for a fact that shorthand will be enabled on whatever servers, then use it if you want.For example: if you are the web admin, and you have shorthand enabled, then you can easily and reliably use shorthand. If you're the web admin, after all, I doubt you're going to be migrating your website to a hosting service any time soon...unless you get fired and don't have the resources available you had before (processing power and bandwidth)... Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154362 Share on other sites More sharing options...
genericnumber1 Posted January 6, 2007 Share Posted January 6, 2007 <?php echo $variable ?>vs<?= $variable ?>I only use <?= on templates so whoever is using them can read them more easily.I believe though (big chance that this is wrong) that some standards (I dunno which) suggests all dynamic languages to be called by their opening tag (<?) followed by a 3 letter identifier (php). Please correct me if I'm wrong... Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154365 Share on other sites More sharing options...
ki Posted January 6, 2007 Share Posted January 6, 2007 On all the servers ive used, shorthand was always allowed. I prefer short hand, I believe it looks somewhat professional in coding, even tho im the only one who sees it. ;) Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154370 Share on other sites More sharing options...
ryld Posted January 6, 2007 Share Posted January 6, 2007 On the contrary, I don't think it looks professional at all. I like everything to be plainly and obviously declared with no room for obscurity or question.I guess I'm oldschool in thought maybe?There will always be multiple institutions of learning. Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154374 Share on other sites More sharing options...
alpine Posted January 6, 2007 Share Posted January 6, 2007 It was discussed wether to kill the short tags from php6, it seems however that it's desided to allow <? for now. But who knows in future releases, i would stick to <?phphttp://php6dev.blogspot.com/#remove-support-for-and-script-language-php-and-add-php-var Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154531 Share on other sites More sharing options...
ki Posted January 7, 2007 Share Posted January 7, 2007 [quote author=alpine link=topic=121290.msg498474#msg498474 date=1168125368]It was discussed wether to kill the short tags from php6, it seems however that it's desided to allow <? for now. But who knows in future releases, i would stick to <?phphttp://php6dev.blogspot.com/#remove-support-for-and-script-language-php-and-add-php-var[/quote]Well I think shorthand is better due to the fact that most coders use it and also for code such as this.[code]<input type="text" value="<? echo $_GET['value']; ?>">[/code]And things like that. Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154583 Share on other sites More sharing options...
Jessica Posted January 7, 2007 Share Posted January 7, 2007 ki:<?=$_GET['value']?> Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154587 Share on other sites More sharing options...
emehrkay Posted January 7, 2007 Share Posted January 7, 2007 <? , the shorthand, is also used in other languages. so <?php is recommended if you're on a server that will parse other languages as well Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154615 Share on other sites More sharing options...
printf Posted January 7, 2007 Share Posted January 7, 2007 This one still works on all servers. from the old PHP/FI days![code]<script language='php'>echo 'hi';</script>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154687 Share on other sites More sharing options...
tallberg Posted January 7, 2007 Author Share Posted January 7, 2007 How do i enable short hand on my wamp server PLEASE? Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154952 Share on other sites More sharing options...
tallberg Posted January 7, 2007 Author Share Posted January 7, 2007 Done it never mind Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-154954 Share on other sites More sharing options...
redbullmarky Posted January 7, 2007 Share Posted January 7, 2007 as has been mentioned, short tags (and also the [url=http://uk.php.net/manual/en/control-structures.alternative-syntax.php]alternative syntax for control structures[/url]) are very useful for templates where you're using PHP as the "template engine" rather than something like smarty.With the popularity of Rails, Smarty, etc, I personally dont think they will actually get rid of them at all, even after PHP6. Most hosts have it on by default, and new downloads/installations of PHP have it turned on by default, too. Ok, so it's not much harder to type in the 'php' bit or 'php echo', but even still - it does keep templates that extra bit tidier. Quote Link to comment https://forums.phpfreaks.com/topic/33133-short-hand-php/#findComment-155071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.