Re: putting variables in a variable



Hulf wrote:
Hi,

I am making and HTML email. I have 3 images to put in. Currently I have

$body .="
<table>
<tr>
<td><img src=\"image1.jpg\"></td>
</tr>

<tr>
<td></td>
</tr>
</table>
";


ideally I would like to have

$myimage1 = "image1.jpg";
$myimage2 = "image2.jpg";
$myimage3 = "image3.jpg";


and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas?


Ross



Since you've used double quotes, It Should Just Work(TM) ...

$body .="
<table>
<tr>
<td><img src=\"$myimage1\"></td>
</tr>
</table>
";

I'd probably use single-quotes (') around the src attribute to avoid those ugly backslashes ...

$body .="
<table>
<tr>
<td><img src='$myimage1'></td>
</tr>
</table>
";

Might be better in this case to use heredoc syntax ...

$body .<<<EndOfChunk
<table>
<tr>
<td><img src="$myimage1"></td>
</tr>
</table>
EndOfChunk;

--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
.



Relevant Pages

  • Re: Preview Panel shows Red x for an Image
    ... Is this a HTML email that you are viewing as HTML? ... Are you sure the picture is in fact included? ... In Tools, Options, Security, Download Images is unchecked. ... I also turned off anti virus scanning in my Norton Internet Security. ...
    (microsoft.public.windows.vista.mail)
  • Re: Outlook HTML Email
    ... -Please post your Outlook version! ... > Email does not display images in email. ... > things for me and I want to be able to view images in HTML email. ...
    (microsoft.public.outlook)
  • Re: HTML emails
    ... it is a reminder of a reasonable html email practice. ... Fundamentalists and purists will say to leave out the html email bit and go straight to plain text and the link. ... When your business is *visual* is just works to have images with associated notes or messages rather than tack all images at the end and have to say in "In image #1 is ..." ... Beats dealing with old AOLers that were also restricted to a single attachment! ...
    (alt.html)
  • Re: [PHP] putting variables in a variable
    ... I am making and HTML email. ... I have 3 images to put in. ... And, for good measure, the array way: ...
    (php.general)
  • HTML email images are converted to attachments when email viewed
    ... HTML email from Earthlink, with embedded images received into INBOX are ... a place holder remains in the email message. ... the HTML images were viewed in the ...
    (microsoft.public.outlook)