[nycphp-talk] heredoc string formatting question
Cliff Hirsch
cliff at pinestream.com
Thu Aug 10 18:07:17 EDT 2006
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.
In the long run, it seems like a template system is the way to go.
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of csnyder
Sent: Thursday, August 10, 2006 4:40 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] heredoc string formatting question
On 8/10/06, Cliff Hirsch <cliff at pinestream.com> wrote:
> Thoughts? Comments?
There are two potential gotchas with the heredoc approach:
1) make sure your editor is using the correct newline character(s)
2) make sure your editor doesn't _ever_ accidentally indent the "EOT;"
The second one is a big deal.
There's really no reason not to just quote the whole thing, is there?
$body = "Hi $name,
Thanks for joining.
$somevariable
Bye!";
Or, if you have an editor that does auto-indent:
$body = "Hi $name,".NEWLINE
."Thanks for joining.".NEWLINE
.$somevariable.NEWLINE
."Bye!";
... though I gues the concatenating dots are easy to miss.
A template system is the way to go if you have to build more than a
few of these, or if you need to generate complex (multi-part html)
messages.
--
Chris Snyder
http://chxo.com/
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
More information about the talk
mailing list