473,671 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

interpolating variables

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:
<html>
Hi there. my name is $name
</html>

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

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

-Magic

Aug 4 '06 #1
5 1300

magic_hat60622 wrote:
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:
<html>
Hi there. my name is $name
</html>

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

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

-Magic
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
text/html??

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.

Aug 4 '06 #2
*** magic_hat60622 escribió/wrote (4 Aug 2006 09:31:59 -0700):
$fh=fopen('./emails/confirmation/index.html', 'r') or die
($php_errormsg) ;
while (! feof($fh)){
$body.=fread($f h,filesize('./emails/confirmation/index.html'));
}

PHP is not interpolating the variable names in the email. Solutions?
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:

{$foo}
%FOO%
[%foo%]

....

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 4 '06 #3

Alvaro G. Vicario wrote:
*** magic_hat60622 escribió/wrote (4 Aug 2006 09:31:59 -0700):
$fh=fopen('./emails/confirmation/index.html', 'r') or die
($php_errormsg) ;
while (! feof($fh)){
$body.=fread($f h,filesize('./emails/confirmation/index.html'));
}

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

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:

{$foo}
%FOO%
[%foo%]

...

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Why not just use .php instead of .html?

Aug 4 '06 #4
dawnerd wrote:
Alvaro G. Vicario wrote:
>>*** magic_hat60622 escribió/wrote (4 Aug 2006 09:31:59 -0700):
>>>$fh=fopen( './emails/confirmation/index.html', 'r') or die
($php_errorm sg) ;
while (! feof($fh)){
$body.=fread ($fh,filesize(' ./emails/confirmation/index.html'));
}

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

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
replacement s. Some ideas:

{$foo}
%FOO%
[%foo%]

...

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--


Why not just use .php instead of .html?
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.
js*******@attgl obal.net
=============== ===
Aug 5 '06 #5

Jerry Stuckle wrote:
dawnerd wrote:
Alvaro G. Vicario wrote:
>*** magic_hat60622 escribió/wrote (4 Aug 2006 09:31:59 -0700):

$fh=fopen(' ./emails/confirmation/index.html', 'r') or die
($php_errorms g) ;
while (! feof($fh)){
$body.=fread( $fh,filesize('./emails/confirmation/index.html'));
}

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

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:

{$foo}
%FOO%
[%foo%]

...

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--

Why not just use .php instead of .html?

Because PHP will still not parse a file read with fread(), no matter
what the extension.
Could turn on output buffering, include a php file + call
output_get_clea n or use str_replace like Alvaro said

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

Aug 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3330
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example I'm adding a customer. The Customer fields are mostly foreign keys that refer to primary keys in other tables, left join instead of junction tables at this point. So, when I want to add a customer record, I also need to add records to the other...
5
11814
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global $MYVAR, $a; ?>
1
2807
by: jitasi | last post by:
Hi all I want to use the matlab function "pchip" in python. I have checked the scipy, but there is only spline Interpolating. Are there any pchip Interpolating in python? Thanks Steven
1
29348
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.