Re: short_open_tag
| From: | Jonathan Sharp | Date: | Tue, 15 Oct 2002 16:56:01 +0000 |
| Subject: | Re: short_open_tag | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-89508@lists.php.net to get a copy of this message | ||
Is it possible to have <?xml not be parsed by php?
I can't think of any situations in which <?xml?> would be php, unless you've define('xml'...). Even then it would most likely by <?=xml?> or <?php xml ?>
So it seems that <? and <?php are valid while <?xml(etc) is ignored.
-js
Dan Hardiker wrote:
The web is a rapidly changing market and standards are being activley evolved. <?php is more compatable with standards on the web than <? ... and its not about XML document headers.I am still +1 on some how getting away from short_open_tag support, if nothing else, to encourage better coding practices (just as we did with turning register_globals off by default).I fail to see how using <?php is "better coding practices". Unless you plan on distributing your code to the masses or mixing XML/XHTML without trivially escaping it, I see absolutely no point in using <?php over <?.In reality, very few people intermix PHP and XML. It just doesn't make a whole lot of sense to do so. People tend to keep the two separate and parse the XML from PHP.I have written semi static XML document from php before (for speed reasons over using an output parser). EG: <?xml ... ?> <root> <data><age><?php echo $age; ?></age></data> </root>In the XHTML case, a lot of people mistakenly believe that they must start their documents with an <?xml encoding=...?> tag, which if you read the XHTML spec, is actually not necessary. The only use for the XML encoding tag is for XML parsers to get the right character encoding. Browsers, which are typically the target of PHP generated pages, get their character encoding from the Content-type header, or optionally from a similar meta tag. But even if you choose to put in the XML encoding tag, I find it a hell of a lot easier to just put <?echo '<?xml encoding="foobar"?>'?> at the top instead of changing hundreds of <? tags to <?phpThe other advantage is to force people one way or the other. In the case of 50% of servers allowing short tags, and the other not... a script using short tags will only work on 50% of PHP installations (just as a script that relies on register_globals will only work on servers with it switched on). The only way around that problem is: 1. to force short tags on everywhere 2. to force people to use a tagging which is available everywherePHP became popular because it eliminated most of the tediousness of writing CGI scripts or low-level Apache modules. If we slowly but surely eliminate all the convenience aspects of PHP we are going to turn the experience back into one of tedium again.Then surely short tags should be forced on in all cases if its a core offering of the php scripting language?PHP is not a pure language. It never will be. The problem it solves is ugly. Ugly problems often require ugly solutions. Solving an ugly problem in a pure manner is bloody hard. PHP's aim is to make solving the web problem easy. Ergo, therefore, Q.E.D, removing all the "ugly" features of PHP is going to make it harder and harder to use PHP to solve the web problem. -Rasmus