Adherence To CI Style Guide |
[eluser]zippy[/eluser]
'short_open_tags' suck. I'm generally bemused - but mostly dismayed - by the ongoing failure of PHP coders of all ages and persuasions to understand the reason why they should avoid using short_open_tags in their code. From the CI 1.7 Style Guide: 'Always use full PHP opening tags, in case a server does not have short_open_tag enabled.' '..in case..?' Uh? What PHP coder/developer doesn't understand that since v5, PHP disables short_open_tags by default? Or even why that is? Clue: how do you embed '<?xml' in a template script when short_open_tags is enabled? So much of the contributed code I've seen is riddled with this. Tighten it up, guys. ;-) Been a cold day here, feelin' miserable.
[eluser]Nick Husher[/eluser]
Short tags are infinitely more readable than full PHP tags. For example: Code: <?=$this_is_readable ?> If you're using third-party templating system (Smarty, for instance), long tags are fine. But then you're committing the cardinal sin of programming, which is reinventing the wheel. PHP is a templating system. Or it was, until someone decided to make it an application platform and started getting all down on the short tag syntax.
[eluser]Randy Casburn[/eluser]
To each his/her own really? Since v5 was mentioned, would it not be fair to mention SimpleXML as one alternative to the brow beating posed by zippy? Put your template in a separate file where it belongs and read it using a parser built to do such things. Or, you can put it into a string which I'm assuming you're doing anyway. But like Nick says, have it parsed by the XML parser, not the PHP parser. When I googled "php xml parser sitepoint" this article came up: http://www.sitepoint.com/article/php-xml...rss-1-0/2/ So if you like short tags, by all means, you have alternatives. On the other hand, if you don't, then you don't need any ;-) Just a thought. Randy
[eluser]Colin Williams[/eluser]
If you are flummoxed by how to mix short tags and an XML prolog, then yes, run and hide from short tags. I think most of us have figured it out though.
[eluser]zippy[/eluser]
Interesting. Thanks for that, chaps. @Nick: I don't 'get' what's less readable about a full php tag. If anything, it's easier to spot in a busy template. And '<?php' ain't the only PI in town, y'nah? @Randy: SimpleXML is way handy, but hungry. And XMLReader has consigned all that other stuff to history. @Colin: flummoxed I'm not. We all know what both CI and PHP recommend. Long tags have always been backward-compatible. We can run, but we can't hide... ;-) Quote:To Infinity! And Beyond! |
Welcome Guest, Not a member yet? Register Sign In |