Reply to (SOLVED) Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация