NYCPHP Meetup

NYPHP.org

[nycphp-talk] heredoc string formatting question

Cliff Hirsch cliff at pinestream.com
Thu Aug 10 17:19:28 EDT 2006


I currently generate email bodies as follows:
 
$body  = "Hi $name. Welcome message.".NEWLINE;
$body .= NEWLINE;
$body .= $somevariable;
$body  .= NEWLINE;
$body .= "More body";
 
It works. It's fairly easy on the eyes. But it's laborious - and
hardcoded.
 
I'm thinking of switching to:
 
$body  = <<<EOT 
Hi $name. Welcome message.
 
$somevariable
 
More body.
EOT;
 
Both approached are hard coded, which has major limitations. I'm a bit
concerned about how line breaks are interrupted by heredoc and
downstream email clients.
 
The other alternative would be a template-driven database approach, but
than the body "variable" would have to be parsed every time.
 
One though I had was to use Smarty to generate tpl files for the email
bodies, letting it do the parsing and compiling.
 
Thoughts? Comments?
 
Cliff
_______________________________
Pinestream Communications, Inc.
Publisher of Semiconductor Times & Telecom Trends
52 Pine Street, Weston, MA 02493 USA
Tel: 781.647.8800, Fax: 781.647.8825
http://www.pinestream.com <http://www.pinestream.com/> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060810/5a2446f1/attachment.html>


More information about the talk mailing list