Hi, I've been running through a few tutorials and examples, and i've noticed that some use different methods to open their code blocks: [B]<?php[/B] //PHP Code [B]?>[/B] Code (markup): Whereas some use: [B]<?[/B] //PHP Code [B]?>[/B] Code (markup): Is there any difference, advantages or disadvantages?
stick with <?php there are no advantages or disadvantages, but some settings on the server might not translate <? as an opening tag for php.
Yeah, you can't go wrong with <?php ..... ?> <?....?> is known as a short tag and there is a possibility of some servers having an issue but then again, the vast majority of our sites running php scripts use <? and we have NEVER had a problem. I've never seen it as an issue in all my years and just about every hosting company are cool with it on their servers. (short_open_tag value to On in the PHP configuration file php.ini) Incidently there are two other ways of enveloping php content: <script language="php"> ---- </script> and <% ... %> If you are writing php from scratch then definately use the <?php tag BUT if you are considering rewriting an existing script becuase of concerns then there is not real need to do this.
<?....?> is almost the same as <?php ..... ?>, but <?php ..... ?> has advantage that it can be used on more platform
I would join to already made opinion but also add that I have never came across hosting where <? ?> are set to be off a lot of php-coders use <?=$var;?> instead of <?php echo $var; ?>
<?php=$var; ?> will also work Anyway, when you program something, use <?php because some web servers won't support <? (like a default install with XAMP, but I would never use XAMP on public web servers).