At Thu, 4 Feb 2010 23:07:36 +0000, Chris G wrote:
The <?php and <? tags are seen by the web server, passed to the PHP module/library/whatever, which is then what processes the PHP code, does business logic/db or file access/etc and then (often) generates HTML which is passed to the webserver and then sent to the client browser. I think. (I don't pretend to know exactly how this works though, so the above is a probable description of what happens given what I have come across and given that I'm a programmer).
Yes, so is the <?php tag just a bodge that only works with, for example, apache2, or what is it? Are there other tags like this possible, e.g. <?perl or <?python ? If not, why not? (I just like logic to my computer programming!)
The pattern of these tags is borrowed from XML processing instructions http://www.w3.org/TR/REC-xml/#sec-pi, which allow XML documents to embed information intended to be passed to the processing application. The most common processing instruction example is the XML declaration which many XML documents include at the top:
_ <?xml version="1.0" encoding="utf-8" ?>
Another one is telling a parsing application to use a particular stylesheet:
_ <?xml-stylesheet href="style.css" type="text/css" ?>
I've used an Python implemented XML template language called Genshi http://genshi.edgewall.org/ in the past which prides itself on its templates being valid (i.e. well formed and validatable against a DTD) XML documents. One of its (admittedly minor) features is that it allows the embedding or verbatim Python code inside a <?python processing instruction, whilst retaining the well formedness of the template document (because arbitrary processing instructions are permitted in XML documents).