[nycphp-talk] Can code be executed in a heredoc?
Dan Cech
dcech at phpwerx.net
Wed Feb 18 12:41:21 EST 2004
James Wetterau wrote:
> Dan Cech says:
>>Indeed, you are correct in that specification allows it, my point was
>>that depending on whether you interpret 'HTML' as HTML 3.2, 4.0, 4.01,
>>XHTML 1.0, or any of the flavours thereof, what is 'technically legal'
>>can vary quite widely.
>
> I believe, but am not certain, that either single or double quotes
> have been acceptable continuously since HTML 1.0. As I mentioned,
> I've used single quotes widely since about 1995 and never noticed
> trouble. It never even occurred to me to give it a second thought
> until this day.
Yes, in both HTML and XML single and double quotes have both been
allowed since the dawn of time (basically because both are allowed in
SGML). My comment was meant in a broader sense in that it is not as
simple as saying the a particular thing is 'valid HTML' as the language
has evolved and what was valid HTML 3.2 may not be valid HTML 4.0, etc.
> I probably first learned the formal description of HTML by looking at
> the HTML draft RFC from June 1993. That RFC describes an attribute as
> being included either between single quotes or double quotes.
> Therefore, it seems that from day one of HTML single quotes have been
> permitted, and were actually the first listed option.
>
> I would be tremendously surprised to learn that some intermediate
> version of HTML had broken backward compatability on this issue.
Indeed, on this particular issue as long as you use a form of quoting
you should be safe in terms of adhering to the standard. The major
reason I tend to use double-quotes is that it makes it easier to include
quotes within attributes.
In XML you can use the ' entity reference to include a literal
single-quote (apostrophe) within a single-quoted string, however I
cannot find any reference to this character being supported in any
flavour of HTML, so you have to use ' to ensure that it is
interpreted correctly by all browsers.
In contrast the " entity reference has been included in both HTML
and XML specs since at least HTML 2.0
(<http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt> Section 9.7.1).
This is supported by all known browsers and thus if double-quotes are
used as the quote characters you can use a literal single-quote
(apostrophe) or the " entity reference to represent any required
quotes in a somewhat readable manner.
I don't want to start a holy war over this, and agree that both
notations are equally valid, I just think that this has turned into a
rather interesting discussion.
Dan
More information about the talk
mailing list