Just curious what people's preferences are. Personally, I can't understand why you'd prefer to open every block of PHP with <?php as opposed to <? other than it maybe being more understandable for beginners... maybe being more obtuse helps? At the same time, how hard is it to get used to <? ... I mean, it actually matches the end tag then, which is common to every other usage of tags in other languages.
Maybe I'm biased by syntax highlighting. <?php and ?> are rendered in a bold red in Dreamweaver, so <?php all over the screen is frankly just distracting, too!
Anyway... your thoughts on this oh so important topic, please.
Two words that will explain why short tags are now turned off by default. xml prologue
Ever seen a full page of nothing from a faultless xhtml+php page?
**for anyone who doesn't know what an xml prologue looks like:
This occurred to me, but after giving it some thought, I wondered how there would be a problem. An XML parser should never seen any <? ?> PHP tags, correct? And the PHP parser should only start parsing if it encounters <? or <?php followed by a space, yes?
Or should I give you the benefit of the doubt and assume no, and rather ask for how my reasoning is flawed?
<? will work when short-tags is turned on.
<?php will work regardless of whether short-tags are turned on or not.
<?xml will be parsed by the PHP parser if short-tags are turned on.
So then the spaces are not required after or before the PHP tags? In Dreamweaver, <?$var=1;?> would not be highlighted as PHP nless the spaces are present. Perhaps syntax highlighting has biased me yet again?
P.S. I've got plenty of short tags in my site, and when viewed through Firefox, for example, it is served as XML, and I've had no issues related to short tags.
<?xml will be parsed by the PHP parser if short-tags are turned on.
usual workaround is to echo such tags
<?echo '<'.'?xml blah';?>
short tags are recommended for re-distributable applications for the reasons noted above.
To be honest this irks me
I personally have yet to meet a server with short tags turned off that I did not have control of anyway (e.g. shared servers),
Turning short tags off also restricts some nice shortcuts <?=$echo_this;?>
Its less typing.
in an average php document , how many XML tags ? how many PHP tags ? EOF
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
usual workaround is to echo such tags
<?echo '<'.'?xml blah';?>
Right, that's what I thought.
Quote:
Originally Posted by firepages
short tags are recommended for re-distributable applications for the reasons noted above.
To be honest this irks me
I personally have yet to meet a server with short tags turned off that I did not have control of anyway (e.g. shared servers),
Turning short tags off also restricts some nice shortcuts <?=$echo_this;?>
Its less typing.
in an average php document , how many XML tags ? how many PHP tags ? EOF
I'm a little confused... you sounded irked by the recommendation that short tags be used, yet proceeded to defend and promote them? I think I misinterpreted something, but I sit confused.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
Heheh, okay. And under that pretense, the full <?php ?> tags make more sense, I guess.
What server administrator would be unwilling to turn on something like that anyway? I mean, did <?php ever have any functional significance over <? or did the short tags just come about when somebody said, "So uh... do I really need to keep typing "php" over and over?"
I use short tags because I don't do anything with XML and I find it easier to output code with the <?= syntax, which is much easier than typing <?php echo
I really like this <?= syntax you guys are talking about. I wasn't aware of this, and had actually been wanting something effectively like that for a while now. Sweeeeet...