On Thu, 2010-02-04 at 21:20 +0000, Chris G wrote:
Moving on, how can one find what *actually* works inside a <SCRIPT> section in HTML? Is it only javascript that really works there in 'most' browsers or are there other possibilities?
It is pretty much just JavaScript. If you are prepared to tie yourself down to Windows and IE you can use VBScript but personally I wouldn't.
The other question is how does <?php work at all? I can't find anything that documents how or why it should allow PHP to do things. I'm maybe missing something obvious but given Google's total inability to look for such things doing any sort or searching is a bit difficult. I have O'Reilly books on HTML and PHP but neither of them really addresses how this works.
I do realise that <SCRIPT> starts client side scripting so is limited by what's implemented in browsers, however it is at least a 'proper' HTML element. <?xxx seems more of a bodge, is it actually a bodge or is there some smeantic/syntactic logic to it?
If you've ever programmed in C this is a bit like working with the pre-processor, i.e. things like #include and #define are not part of the C language (though they later got standardised) but specify a transformation that happens to the C program before the compiler sees it.
Likewise with <?php which specifies a transformation that happens to the file on the server before it hits the user's web browser. The <? was no doubt chosen to avoid the possibility of a clash with anything anyone would want to write in HTML. Starting this marker with a < character means it will not clash with any normal text as that would have < characters converted to the < entity so as to avoid a clash with tags and having ? as the second character as ? means it doesn't clash with any HTML tags as these all start with letters. Interestingly XML has a similar thing. In XML <? starts a 'processing instruction'.
One usually thinks of this kind of hybrid page as embedding code in HTML but in practice what normally happens is that when a user tried to access the page it is converted into code in the language that appears to be embedded in the HTML HTML portions turned into strings and that code is executed. For better performance that compiled version maybe cached. An example of this is JSP where a JSP page gets compiled into a servlet.
Steve.