interpolating variables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi all. I have an html file that I need php to read and send as an html
e-mail. The file contains standard html and also some variable names
that I want php to interpolate:
Hi there. my name is $name

I'm reading the file like so:
$fh=fopen('./emails/confirmation/index.html', 'r') or die
($php_errormsg) ;
while (! feof($fh)){

PHP is not interpolating the variable names in the email. Solutions?


Re: interpolating variables

magic_hat60622 wrote:
Quoted text here. Click to load it

Why not just put the html of the message you want to send into a
variable in that script??
Are there reason why your reading a file for such a small amout of

Just seems to be more work then needed unless you have users making
these files and want them to be in a static place for your script to
read from.

Re: interpolating variables

*** magic_hat60622 escribió/wrote (4 Aug 2006 09:31:59 -0700):
Quoted text here. Click to load it

Thanks God, PHP does not treat all files it reads as PHP code! Just use
str_replace() on $body to replace the values you want. I suggest, though,
that you chose another markup that's not so prone to undesired
replacements. Some ideas:



-+ - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web:
+- Mi web de humor con rayos UVA:

Re: interpolating variables

Alvaro G. Vicario wrote:
Quoted text here. Click to load it

Why not just use .php instead of .html?

Re: interpolating variables

dawnerd wrote:
Quoted text here. Click to load it

Because PHP will still not parse a file read with fread(), no matter  
what the extension.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: interpolating variables

Jerry Stuckle wrote:
Quoted text here. Click to load it

Could turn on output buffering, include a php file + call
output_get_clean or use str_replace like Alvaro said

Thats if a template is necessary though, slimdizzy had a point

Site Timeline