SitePoint Sponsor

User Tag List

View Poll Results: Do you use short tags

Voters
55. You may not vote on this poll
  • Yes

    10 18.18%
  • No

    45 81.82%
Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 56
  1. #26
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use short tags in my php-based templates (when I'm forced to use them). Why? Because "<?php echo" instead of "<?=" is just stupid and I don't like feeling like that.

  2. #27
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Used to use them but dont now.
    Reason? No idea, it just seemed like a better idea not to rely on external factors to ensure that your app works as YOU intend it.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #28
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'll be honest - I've NEVER used PHP short tags, even though I come from an ASP background and the tags are short by default <&#37; %>
    Ian Anderson
    www.siteguru.co.uk

  4. #29
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    I'll be honest - I've NEVER used PHP short tags, even though I come from an ASP background and the tags are short by default <% %>
    That brings up an interesting question: how do XML parsers react when they encounter ASP-style tags?

  5. #30
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    XML parsers see the rendered output don't they? Therefore they'll never see <&#37; %> tags. The issue with PHP short tags is that <?xml confuses the PHP parser, not the XML parser. (Unless I have understood something wrongly here).

    Edit:

    Just noticed that I have passed my 5th anniversary as a Sitepoint forum member.
    Ian Anderson
    www.siteguru.co.uk

  6. #31
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Long Tags for me. They are 'best practice' for a reason, and those reasons have already been discussed. Don't think I need to elaborate further!

  7. #32
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Off Topic:


    Congrats Ian!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #33
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    XML parsers see the rendered output don't they? Therefore they'll never see <% %> tags. The issue with PHP short tags is that <?xml confuses the PHP parser, not the XML parser. (Unless I have understood something wrongly here).

    Edit:

    Just noticed that I have passed my 5th anniversary as a Sitepoint forum member.
    What if it isn't processed by ASP first, but goes to the XML parser with the ASP code intact? With the PI-style <?php tag, the XML parser would presumably ignore it, as it's clearly a PI intended for a different processor.

  9. #34
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If it isn't processed by ASP first then ...

    a) You shouldn't be trying to XML parse a file that is patently NOT an XML file - it can only be XML compliant AFTER the ASP parser has run;

    and/or

    b) You shouldn't be trying to run an ASP page on a non-ASP server. If you do and the XML parser finds errors then - Gee whizz! What a surprise!

    IMHO there isn't even any discussion here in relation to XML parser and ASP tags, or even PHP tags (short or otherwise) - the above a) and b) arguments apply equally to PHP.
    Ian Anderson
    www.siteguru.co.uk

  10. #35
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ok, maybe this is a possible fix for PHP6. How about two important changes, which will narrow the gap.

    1) Disable PHP output if the word XML is placed directly after it
    2) Allow the quick template approach in long tags, e.g.
    PHP Code:
    <?php $var ?>
    That would presumably mean that your choice of tags is completely down to a matter of choice.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  11. #36
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    If it isn't processed by ASP first then ...

    a) You shouldn't be trying to XML parse a file that is patently NOT an XML file - it can only be XML compliant AFTER the ASP parser has run;

    and/or

    b) You shouldn't be trying to run an ASP page on a non-ASP server. If you do and the XML parser finds errors then - Gee whizz! What a surprise!

    IMHO there isn't even any discussion here in relation to XML parser and ASP tags, or even PHP tags (short or otherwise) - the above a) and b) arguments apply equally to PHP.
    Right, right. It's not something you would do unless you were truly bored. (Mother told me if I had a brain I'd play with it, and she was right! )

    The fact is, though, that a document containing a PI of the form <?application is valid XML. Therefore, you should be able to pass it to an XML processor with no problems. Whether you would want to do so is another matter.

  12. #37
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    However - Why would you set your server to parse XML files in the first place? IMHO, if you separate programming from output (which, technically, you should do), you shouldnt have a problem - For example, use a XML class instead of inefficiently using PHP to directly output database content.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  13. #38
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    However - Why would you set your server to parse XML files in the first place? IMHO, if you separate programming from output (which, technically, you should do), you shouldnt have a problem - For example, use a XML class instead of inefficiently using PHP to directly output database content.
    Frankly, I wouldn't use XML at all if the data was only ever going to be processed on the same server. In my opinion, XML is only worthwhile when sharing data between disparate systems. Even at that, I'd ascertain that RESTful URIs wouldn't accomplish my objectives more easily and efficiently before going with XML.

    That said, I've been speaking hypothetically, without regard to what one might do or should do. Sorry I haven't been able to make that clear.

  14. #39
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I read somewhere that using the short tags can increase your risk of cancer. I'm not saying you'll definitely get cancer, just something to be aware of.

  15. #40
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Imo short tags is an abomination which should have been removed together with the asp tags in php 6. Its not difficult to write a few characters more, after all you usally only do it once per file...

    For those mixing the tags, you would need to stop that with php 6. According to the documentation, they will not allow mixing the tags.

    Quote Originally Posted by arkinstall View Post
    2) Allow the quick template approach in long tags, e.g.
    PHP Code:
    <?php $var ?>
    That will never happen, its already been stated.
    http://www.php.net/~derick/meeting-notes.html#id66

  16. #41
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the link.

    Anyone know why it's not to be added?
    Also, what do they mean by mixing open/close tags?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  17. #42
    SitePoint Enthusiast traxxas's Avatar
    Join Date
    Jan 2007
    Location
    San Diego, CA
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Disallowing mixing open close tags means:
    Code:
    <?php $foo='bar'; &#37;>
    <% ?>
    I imagine they aren't adding <?php = because they are leaving in <?= and there is no need to have yet another tagging option when there are trying to reduce the tags as is.

  18. #43
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    Its not difficult to write a few characters more, after all you usally only do it once per file...
    This is not the case if you use php not only for your classes, but also for your templates. The short tags haters should realize that disabling this feature essentially kills php as a "templating language".

  19. #44
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't be lazy, type "php" after "<?" and your potentials problems are solver

  20. #45
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure what you mean by "your potentials problems are solver", care to explain yourself better?

    This is not about being "lazy" or what. Compare:
    PHP Code:
    <?=$username?>
    and
    PHP Code:
    <?php echo $username?>
    Do you see 8 (eight) extra characters in the second snippet, that have absolutely no meaning. You can count can't you? This is eight symbols: 'php echo'. Multiply by the number of echo statements in the template, say 50. 400 (four hundred) symbols that mean nothing at all. Quite a lot.

    I'm just wondering why do you love those characters that much. Perhaps, you're feeling happy typing useless symbols? Or you believe that cryptic spells will make your life better? Anyways, educate yourself about CTS and please please stop worsening your karma and polluting the environment by producing large amounts of useless waste.

  21. #46
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Thanks for the link.

    Anyone know why it's not to be added?
    If they're already removing <&#37; %> and <script> then they'll have removed unnecessary tagging methods. However <?php =variable ?> is not a tagging method per se - it's an echoing method ... using = instead of echo. The linked page doesn't say why they won't do this, just that they won't. IMHO this is a short*-sighted viewpoint.

    * pun intended.
    Ian Anderson
    www.siteguru.co.uk

  22. #47
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by stereofrog View Post
    This is not the case if you use php not only for your classes, but also for your templates. The short tags haters should realize that disabling this feature essentially kills php as a "templating language".
    Imo that statement is a little on the edge.

    I use php as a lightweight template system as well and I dont use short tags.

    Personally I feel its much easier reading code without short tags. I.e. its easier to notice <?php echo $var;?> in the template code than it is to notice <?=$var?>

    Quote Originally Posted by stereofrog View Post
    This is not about being "lazy" or what. Compare:
    PHP Code:
    <?=$username?>
    and
    PHP Code:
    <?php echo $username?>
    Do you see 8 (eight) extra characters in the second snippet, that have absolutely no meaning. You can count can't you? This is eight symbols: 'php echo'. Multiply by the number of echo statements in the template, say 50. 400 (four hundred) symbols that mean nothing at all. Quite a lot.

    I'm just wondering why do you love those characters that much. Perhaps, you're feeling happy typing useless symbols? Or you believe that cryptic spells will make your life better? Anyways, educate yourself about CTS and please please stop worsening your karma and polluting the environment by producing large amounts of useless waste.
    We are not taking this personal are we?

    As I said earlier, its a personal opinion and choice if you should use them or not.

    Though I feel your argument is a little thin, the extra characters does not add any excess weight to the file and the execution of the code. Nor does it take that much longer to write those eight extra (actually nine, you forgot the ending semicolon) characters. Compared to the readability you get in return (imo).

    Not sure what you mean by CTS though, perhaps carpal tunnel syndrome?

  23. #48
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    As I said earlier, its a personal opinion and choice if you should use them or not.
    It would be so if short tags weren't officially deprecated and "unrecommended".
    Though I feel your argument is a little thin, the extra characters does not add any excess weight to the file and the execution of the code. Nor does it take that much longer to write those eight extra
    Well, you personally, do you actually type all those "php echo's" or use a keyboard shortcut or some kind of your IDE's macro?

    (actually nine, you forgot the ending semicolon) characters.
    I didn't, it's optional.

    Compared to the readability you get in return (imo).
    As said, a matter of taste. You say readability, I say visual clutter.

    Not sure what you mean by CTS though, perhaps carpal tunnel syndrome?
    Yes, exactly that (and unlike the cancer comment above, I'm not kidding).

  24. #49
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used to use it but NOT now because i have already failed in at least two projects in case of PHP upgrades. Yes once again don't be so lazy to type that standard PHP tag so that you don't have to take any risk at all whatever cases comes over and over. And even you don't have to type it if you are using Dreamweaver just click and it will automatically write for you.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  25. #50
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by stereofrog View Post
    It would be so if short tags weren't officially deprecated and "unrecommended".
    Touche

    Quote Originally Posted by stereofrog View Post
    Well, you personally, do you actually type all those "php echo's" or use a keyboard shortcut or some kind of your IDE's macro?
    I type them by hand.

    Quote Originally Posted by stereofrog View Post
    I didn't, it's optional.
    Indeed, but it looks so much better with it... Sorry just had to.

    Quote Originally Posted by stereofrog View Post
    Yes, exactly that (and unlike the cancer comment above, I'm not kidding).
    I wouldnt belive you would be kidding about that. Ive had issues with that as well as some issue with my shoulder in the past as well, still go regulary to a physiotherapist as well as train several times a week to keep it a bay.

    If you experience problems with it, then I can understand the mindset to type as little as possible.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •