Page 1 of 3
SHort tags
Posted: Wed Feb 11, 2009 7:51 pm
by alex.barylski
Are they not being phased out and generally considered a bad practice?
I started on a new project and the codebase is a mangle of HTML/SQL/PHP/JS/CSS all in a single file. To make matters worse, there are several scripts which do more than one thing.
members.php => Would show a paginated list of members
members.php?id=2 = Would show a single member profile
One of the first things I'm trying to get across to everyone is the importance of separating the HTML from the PHP code and in doing so enforce some standard/convention and NOT use short tags (which is heavily used).
I have googled but is PHP 6 not supporting short tags?
Re: SHort tags
Posted: Wed Feb 11, 2009 7:54 pm
by John Cartwright
If memory serves, they are removing ASP style tags, not short tags.
Sources please?
EDIT | found it -
http://www.php.net/~derick/meeting-notes.html#id66
Re: SHort tags
Posted: Wed Feb 11, 2009 7:57 pm
by Benjamin
They will remove support for the ASP style tags, but the PHP short-code tag will remain (<?)
http://www.corephp.co.uk/archives/19-Pr ... PHP-6.html
They still shouldn't be used however.
Re: SHort tags
Posted: Wed Feb 11, 2009 7:58 pm
by alex.barylski
Sweet, thanks for that link.

Re: SHort tags
Posted: Wed Feb 11, 2009 7:58 pm
by Eran
Personally I consider them bad practice since they are off on some server configurations, making the code less portable.
Re: SHort tags
Posted: Wed Feb 11, 2009 10:47 pm
by alex.barylski
Personally I consider them bad practice since they are off on some server configurations, making the code less portable.
That would typically be a good concern, only in controlled environments that argument doesn't really hold legit weight. Although I could probably say that still and test the waters for rebuttle.
I have my work cut out for me, for sure. Thankfully as developers we crave a challenge.

Re: SHort tags
Posted: Thu Feb 12, 2009 12:41 pm
by s.dot
I would open all of the code in my editor and do a regex replace on '<?\w' and replace it with <?php ;d
Or, if I were nifty with linux I'd do it from the command line.. I do believe a recursive replace is possible.
Re: SHort tags
Posted: Thu Feb 12, 2009 12:43 pm
by Eran
That would typically be a good concern, only in controlled environments that argument doesn't really hold legit weight. Although I could probably say that still and test the waters for rebuttle.

Unless you write different code on different systems, or are writing (and will always write) for one system only, that can not be always true. It's better to get used to writing long-tags than using short-tags when they can break things up.
Re: SHort tags
Posted: Thu Feb 12, 2009 12:46 pm
by s.dot
pytrin wrote:That would typically be a good concern, only in controlled environments that argument doesn't really hold legit weight. Although I could probably say that still and test the waters for rebuttle.

Unless you write different code on different systems, or are writing (and will always write) for one system only, that can not be always true. It's better to get used to writing long-tags than using short-tags when they can break things up.
They sure do throw funny errors, too.
Especially if in included files.. can be hard to figure out where the short tag is.
Re: SHort tags
Posted: Thu Feb 12, 2009 9:48 pm
by josh
Why should I break the habit if I can just run a regexp if I do decide to OS my codebase? ( short tags that is, not mixing cross cutting concerns

)
Re: SHort tags
Posted: Thu Feb 12, 2009 9:52 pm
by John Cartwright
Nobody is forcing you to use the long php tags. However, the point being made is situations
may arise where short tags are disabled. If such a situation can be avoided, and subsequently making code more portable, then why not is the question?
Seems like someone is playing devils advocate

Re: SHort tags
Posted: Thu Feb 12, 2009 10:08 pm
by josh
Well to prove something you can disprove it's contradiction, was just trying to derive wether or not its bad practice! I say no!
hahahaha cheers
Re: SHort tags
Posted: Fri Feb 13, 2009 5:43 pm
by alex.barylski
I was sure I mentioned the server is in our direct control so disabling short tags is not a concern. If it's being phased out, that argument would hold far more weight, but apparently they are keeping them, so I guess were keeping the tags.
Re: SHort tags
Posted: Fri Feb 13, 2009 5:47 pm
by Eran
I was sure I mentioned the server is in our direct control so disabling short tags is not a concern. If it's being phased out, that argument would hold far more weight, but apparently they are keeping them, so I guess were keeping the tags.
I was referring directly to what you said. If you believe you will work on this server for this company for the rest of your career then it shouldn't be a problem. For the rest of us.. I think it's probably not the case
Re: SHort tags
Posted: Sat Feb 14, 2009 1:32 pm
by alex.barylski
I don't think I'll work here for the rest of my career...I will be here for a while though...when I am satisified I have done everything I can for the project and they are in good hands I will likely persue other projects...but yes the server will always be in their direct control.
Short tags are nice in alternative syntax templates though...