How do you enclose PHP tags..

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

How do you enclose your PHP tags ?

I use <?php ?>
14
78%
I use <? ?>
4
22%
 
Total votes: 18

User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

How do you enclose PHP tags..

Post by igoy »

I was just wondering this morning while I was coding...

How do other people write PHP tags...
that is, do they use <?php ?> or just <? ?>, and why ?

I mean I started my PHP coding with <? ?> coz' it was simple and easy to write, but now I use <?php ?> :), why ?
just because I love PHP.

so please let me know what do you use and why..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

since <?php always work and <? not I use <?php
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Also <?php although until recently, I was using <?. I got errors popping up all over the place since I needed to use <?xml version=1?>, for my XHTML documents. Then I turned the short tags off and just use <?php for everything.

Since then, my hands have just been used to typing <?php :lol:...

-Nay
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Imho short tags are an irritating source of potential errors. Sooner or later a script written with short tags will get installed somewhere they're not enabled resulting in fire, flood and earthquakes.

An accident just waiting to happen.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Using XML so <? ?> is a definite no no for me. Plus, as others have mentioned, it can be disabled so it's not reliable. <?php ?> is a much better option IMHO.

Mac
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

i got stuck with the <?php because i read in my book that there are compatibility problems when designing pages with XML content or XHTML...
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

<?php of course... Since it is sufficiently unique.
I think you should have added <script language="php"></script> to the poll options since I havn't seen anyone using it...
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

<? ?>

Why? Less typing. :)

If someone does install it on a system without short tags enabled, it's a simple matter of leaving a note in a README file or enabling it yourself. I'd never stop using this way because of incompatability issues. That's like never coding gd or ming because it might not be enabled on the server someone else might have configured differently. ;)
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

I use <? ?> but after reading these posts I'm going to change to <?php ?> to save future headaches :wink:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but it makes it more difficult to hande xml (as mentioned by twigletmac)

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

I vote for <?, have been using it for a long time, now I tend to use <?php due to compability and portability issues...

But when it comes to use <?= what do you switch to? <?php echo?

Cheers,
Scorphus.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

if u have short tags enabled u will have to use:

Code: Select all

<?php echo "<?xml version="1.0" encoding="ISO-8859-1"?>"; ?>
to use xml
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It's probably something to note, that if you're using <? ?>, you are at the mercy of server configurations as well as having to face the possibility that the PHP dev team may remove the option for short tags altogether because of compatibility issues with XML. Not saying they will but they did turn off register_globals, so I doubt short tags are sacred to them.

Mac
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Hmmm.. Interesting

Post by igoy »

:D Cool... I started using <?php ?> because I loved working on PHP so much that I wanted my tags to scream "Yeah, I'm PHP tag"... LMAO.. :)

never thought about compatibility.. o_0 ..

Well, good thing in disguise... hehehe :wink:
marzipan
Forum Newbie
Posts: 2
Joined: Mon Nov 03, 2003 12:26 pm
Location: Ohio

Post by marzipan »

You should use <? php at least at the start of the page, and definitely everytime you have a code snippet if you're mixing in other technologies on the page.

Don't forget to //document your functions. It's the best gift you can give to yourself as a newbie. If you're consulting, clients will really appreciate the professionalism of easy to read, easy to understand code.

For instance, //this code rocks, or //I rule, look here :lol:
Post Reply