zohab Posted June 4, 2008 Share Posted June 4, 2008 hi all any one know the difference between <?php and <? example <?php echi "hi"; ?> and <? echo "hi"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/ Share on other sites More sharing options...
peranha Posted June 4, 2008 Share Posted June 4, 2008 <? is the short version, and may not be supported on some servers. Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557165 Share on other sites More sharing options...
haku Posted June 4, 2008 Share Posted June 4, 2008 It is a setting on the server. The problem with using the short tags (<?) is that the server admin could change the setting without the developer knowing, causing any scripts using short tags to fail until the developer realizes there is an issue. The other problem is that if the developer decides to switch servers some day, and the new server doesn't support short tags, the script will fail. As such it is considered bad practice to use short tags. Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557170 Share on other sites More sharing options...
Cosizzle Posted June 4, 2008 Share Posted June 4, 2008 I think the most simple answer is laziness Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557198 Share on other sites More sharing options...
Zane Posted June 4, 2008 Share Posted June 4, 2008 one difference with short tags is that you can do this ="Hell World" ?> or ="It is" . time(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557248 Share on other sites More sharing options...
bilis_money Posted June 4, 2008 Share Posted June 4, 2008 <?php is the most recommended one. Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557254 Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2008 Share Posted June 4, 2008 Even php.net itself recommends against using short open tags - ; NOTE: Using short tags should be avoided when developing applications or ; libraries that are meant for redistribution, or deployment on PHP ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. Short open tags also causes problems when xml is embedded in a php file, because the php parser was never made smart enough to know that <?xml is not a short open tag followed by the letters xml. Several things were added in php's early versions to "magically" save a lazy-way programmer time when he was typing code, but in each of these (short open tags, magic quotes, register globlas...) they have caused much much more wasted time to troubleshoot the problems they caused in code that stops being parsed when moved between servers with different settings (short open tags), wasted execution time to remove slashes automatically added by the language because they don't escape all the special characters (magic quotes), or in hacked sites (register globals) then they ever saved the programmer when he was typing the code. Programming languages should be a programming language first and a "magic" act - never. [/rant] Quote Link to comment https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557362 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.