|
Posted by Jeff Schmidt on 03/15/05 05:00
Ok, well the mystery is solved. Earlier in the script, I had used
HEREDOC string delimiting to output some html blocks (I feel,
asthetically, that HEREDOC is more readable than escaping out to HTML
then back into PHP). Somehow, and I'm not sure how, because I don't
remember typing the spaces, but somehow, exactly 4 spaces got inserted
after each of my heredoc delimiter tokens in my script. Well, PHP isn't,
apparently, smart enough to ignore the white space after the delimiter,
and decided that the entire rest of my script constituted one large
HEREDOC block.
I only caught this after putting a copy of my script on my webserver
with .phps extension and looking at it, and noticing that after the
heredoc, all syntax highlighting stopped.
So, I guess even though HEREDOC might be more pleasing to read (imho),
it has a nasty class of syntax error that is *very* hard to detect
(since it is very hard to 'see' that you have whitespace after the
token). Caveat coder.
Actually, I think I just figured out where the whitespace came from. My
text editor has a feature, normally usefull, to do automatic indenting
when you start a new line of code. I think it indented the cursor 4
spaces, and I hit 'home' and typed the delimiting token, and forgot
about the whitespace at the end (normally, whitespace is
ignored/collapsed by the parser).
Jeff Schmidt
[Back to original message]
|