NYCPHP Meetup

NYPHP.org

[nycphp-talk] heredoc string formatting question

michael lists at genoverly.net
Thu Aug 10 19:05:08 EDT 2006


On Thu, 10 Aug 2006 18:07:17 -0400
"Cliff Hirsch" <cliff at pinestream.com> wrote:

> Thanks to all -- excellent suggestions all around. In summary, heredoc
> seems to be a waste. Too much room for error with a finicky editor and
> no major added benefit.

(Hans Z, you knew this was coming..)

On the contrary, I think heredoc is a very valuable tool to have.

Whether you are writing out a long mail message or a long html
section, and all you have to do is drop a few variables, then heredoc
is great.  I think it is especially easier to read the 'native'
language in this format (whether it is straight text or tagged html)
than flipping in-and-out of <?php ?> tags everywhere with dots and
quotes, newlines and linefeeds, and other punctuation... blah. It also
relieves you having to watch out for escaping single or double quotes
and other escapables. You just write what you want to write, the way you
have always written it. From experience I know that it makes revisiting
code much easier.

For short ones, like Mr. Snyder said, just quote the whole thing.

> In the long run, it seems like a template system is the way to go.

arrgg.. no offense the poster.. but.. why is adding abstraction and
complexity always the answer?   Be a Smarty; don't drink that punch or
eat those pears.  <very_old_rant /> PHP *is* a templating language!

Maybe I'm old fashioned but clean and simple is my first effort.

-- 

Michael



More information about the talk mailing list