NYCPHP Meetup

NYPHP.org

[nycphp-talk] Can code be executed in a heredoc?

Adam Maccabee Trachtenberg adam at trachtenberg.com
Wed Feb 18 01:25:19 EST 2004


On Wed, 18 Feb 2004, Dan Cech wrote:

> Adam Maccabee Trachtenberg wrote:
> > On Tue, 17 Feb 2004, Daniel J Cain Jr. wrote:
> >
> >>Is it bad form to use the format below?  Instead of escaping all double
> >>quotes to use single quotes for the tag attributes.
> >>
> >>echo "<a href='http://www.nyphp.org'>Link Test</a>";
> >
> > While that is technically legal HTML, until someone can prove it to me
> > otherwise, I've never trusted that some stupid browser won't barf on
> > it.
>
> The term 'technically legal HTML' is about as broad as you can get, but
> yes it is more or less acceptable.  However the convention is to use
> double-quotes to enclose attribute values in html/xhtml/xml.

Define "more or less acceptable."

All I'm saying that the specification allows it (hell, it even allows
you to omit quotation marks of any sort in some cases), but that I
don't trust that UAs correctly implement the spec.

http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2

Whether the convention is to use double quotes or single quotes is a
different issue.

> > For XML, I'm willing to do this, since I usually have control over the
> > parser and I'm willing to trust (for some reason) that XML parsers get
> > this right.
>
> I can't really comment on how xml parsers would handle this, the w3c
> specs (at first glance) don't seem to specify the exact quoting method
> which is 'valid', but here again the generally accepted norm seems to be
> double-quotes.

Huh? It's pretty clear (or as clear as W3C specs get):

http://www.w3.org/TR/2004/REC-xml-20040204/

Literal data is any quoted string not containing the quotation mark
used as a delimiter for that string. Literals are used for specifying
the content of internal entities (EntityValue), the values of
attributes (AttValue), and external identifiers (SystemLiteral). Note
that a SystemLiteral can be parsed without scanning for markup.

Literals
[9]   EntityValue   ::=   '"' ([^%&"] | PEReference | Reference)* '"'
                          |  "'" ([^%&'] | PEReference | Reference)* "'"
[10]  AttValue      ::=   '"' ([^<&"] | Reference)* '"'
                          |  "'" ([^<&'] | Reference)* "'"
[11]  SystemLiteral ::=   ('"' [^"]* '"') | ("'" [^']* "'")
[12]  PubidLiteral  ::=   '"' PubidChar* '"'
                          | "'" (PubidChar - "'")* "'"
[13]  PubidChar   ::=   #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]

Like I said, if you squint you can see that you can use single or
double quotes.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!



More information about the talk mailing list