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.
| SitePoint Sponsor |
Yes
No





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.


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 Leader
Only a woman can read between the lines of a one word answer.....
I started out with nothing... and still got most of it left!





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 <% %>![]()










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.![]()


Off Topic:
Congrats Ian!
Mike Swiffin - Community Team Leader
Only a woman can read between the lines of a one word answer.....
I started out with nothing... and still got most of it left!










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.![]()
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.
That would presumably mean that your choice of tags is completely down to a matter of choice.PHP Code:<?php = $var ?>
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona





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.
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





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.





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.





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.
That will never happen, its already been stated.
http://www.php.net/~derick/meeting-notes.html#id66
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
Disallowing mixing open close tags means:
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.Code:<?php $foo='bar'; %> <% ?>










Don't be lazy, type "php" after "<?" and your potentials problems are solver![]()





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:
andPHP Code:<?=$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.PHP Code:<?php echo $username?>
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.





If they're already removing <% %> 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.![]()





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?>
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?





It would be so if short tags weren't officially deprecated and "unrecommended".
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?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
I didn't, it's optional.(actually nine, you forgot the ending semicolon) characters.
As said, a matter of taste. You say readability, I say visual clutter.Compared to the readability you get in return (imo).
Yes, exactly that (and unlike the cancer comment above, I'm not kidding).Not sure what you mean by CTS though, perhaps carpal tunnel syndrome?
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.





Touche
I type them by hand.
Indeed, but it looks so much better with it...Sorry just had to.
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