Re: how can I use an external 'template' file and still use PHP variables?

From: Date: Fri, 10 Jan 2003 10:12:54 +0000
Subject: Re: how can I use an external 'template' file and still use PHP variables?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-131073@lists.php.net to get a copy of this message
"Daevid Vincent" <daevid@daevid.com> wrote: > I've posted this a few weeks ago with no response. I want to use an > external > "email template" as it were, so that the sales guys can edit it as they > like and simply shuffle the variables around that they need > $username and $password (either with or without the <?php ?> tags). > > I don't want them mucking around in my code and potentially screwing it > up. Not to mention having a huge 'email' text in between those > HTMLMESSAGE markers is ugly as hell and ends up making the color-coding > in HomeSite all kinds of whack at the end of it. > > I tried to use: > > $message = <<<HTMLMESSAGE > include("/pathto/customer_email.php"); > HTMLMESSAGE; > > But $message has the literal string > ''include("/pathto/customer_email.php");'' instead of including > the > file. Grr.. (wouldn't it make sense that an include() should be parsed > FIRST with the contents put in place basically? This seems like a 'bug' > not a feature. Well, include() will parse the file--maybe you're just doing it the wrong way... ;) I'm not sure how your customer_email.php looks like but consider this: <?php $name = "General PHP"; include "inc.php"; echo $message; ?> Then in inc.php you have: <?php $message = "$name, how are you doing?"; ?> Running the first script should echo: General PHP, how are you doing? So, as you can see the $name was replaced. Just a simple example... - E ...[snip]... __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

« previous php.general (#131073) next »