AshMan Posted January 31, 2003 Share Posted January 31, 2003 (edited) What is the difference between using <?PHP ?> and <? ?> In your PHP code? Does adding the "PHP" do anything? Edited January 31, 2003 by AshMan Link to comment Share on other sites More sharing options...
0 Guspaz Posted January 31, 2003 Share Posted January 31, 2003 Depends on your config. Some PHP installs will let you use the shorter <? ?>, some force you to use the full-length <?php ?> Link to comment Share on other sites More sharing options...
0 aco Veteran Posted January 31, 2003 Veteran Share Posted January 31, 2003 Putting "php" after the opening question mark makes PHP code more friendly to XML parsers. AFAIK it's not needed. Link to comment Share on other sites More sharing options...
0 Tim Dorr Veteran Posted January 31, 2003 Veteran Share Posted January 31, 2003 ALWAYS use <?php. It'll help XML parse correct. Some times other scripting languages use the <?something syntax, and then you'll be screwed if they overwrite your code or remove it. Plus, they may remove it in the future, who knows? Just to guarantee the least headaches, use <?php Link to comment Share on other sites More sharing options...
0 Marshalus Veteran Posted January 31, 2003 Veteran Share Posted January 31, 2003 A site I used to do web development for was on an NT server that would ONLY allow <? ?> ... odd stuff. Link to comment Share on other sites More sharing options...
0 BxBoy Posted January 31, 2003 Share Posted January 31, 2003 I usually just use <? and ?> in my scripts.. I guess I should start using <?php Link to comment Share on other sites More sharing options...
0 RaQ Posted January 31, 2003 Share Posted January 31, 2003 What is the difference between using<?PHP ?> and <? ?> In your PHP code? Does adding the "PHP" do anything? Eventually <?> etc won't be suported only <?php> infact the next build is rumored NOT to have full support for <?> they will slowly be doing away with it. Link to comment Share on other sites More sharing options...
0 NeoMayhem Posted January 31, 2003 Share Posted January 31, 2003 They do the same thing, and in the PHP.ini file you can disable the <? version. ASP and other PHP style scripting languages use <? so if you use <?PHP it sets it apart, and it will work on all servers if they have disabled <? ;) So just use <?PHP is adding 3 letters that hard? Link to comment Share on other sites More sharing options...
0 AshMan Posted January 31, 2003 Author Share Posted January 31, 2003 Thanks for the advice guys. The reason I had asked was because I am new at PHP, only my third week into it and am loving it. I had a look at many example codes, both online and in books but people were being inconsistant. Some were using "<?PHP" and others just "<?" so I was getting kind of confused. Link to comment Share on other sites More sharing options...
0 Cubano Posted February 1, 2003 Share Posted February 1, 2003 To add to the informative replies, one of the main details about programs, in whichever language, is that they must be somewhat portable. Some hosts might support the <? ?> tags, but some may not and that is when it becomes troublesome, when you have to go back and fix everything throughout your code. This makes programming highly inneficient. Link to comment Share on other sites More sharing options...
Question
AshMan
What is the difference between using
<?PHP
?>
and
<?
?>
In your PHP code? Does adding the "PHP" do anything?
Edited by AshManLink to comment
Share on other sites
9 answers to this question
Recommended Posts