0

this should be an easy question but im finding it hard to get a working answer, i am using Sendgrid php api and it requires that i do the following code in this layout.

in my code i have:

//this part is the sendgrid part:
$email->addContent(
    "text/html", "//i need to put the bottom image code into here"

<?php echo '<img src="data:image/png;base64,'.base64_encode($portal['image']).'"width="1024px" height="768px"/>'; ?>




the end result should look something like:

$email->addContent(
    "text/html", "<img src="data:image/png;base64,'.base64_encode($portal['image']).'"width="1024px" height="768px"/>"


i cant figure out how to use the correct quotes so that this code will work since it uses double and single quotes inside of eachother

1 Answers1

0

You have to match the starting and ending quotes for a string. You're starting the first string with ", but then ending it with ' before the concatenation ..

If you want to put double quotes inside the string, use single quotes around it, and vice versa. If you need to include the same kind of quote inside the string as you use two create it, you have to escape the inner one.

$email->addContent(
    "text/html", '<img src="data:image/png;base64,'.base64_encode($portal['image']).'" width="1024px" height="768px"/>'
Barmar
  • 741,623
  • 53
  • 500
  • 612