-3

I am sending an email with PHP and i want the email sent to have PHP in it but for some reason it doesn't work. How can i include PHP in the email sent?
This is the code that writes the email

Theo27
  • 385
  • 4
  • 17
Gomes
  • 11
  • 2
  • Why is this tagged with `javascript`? – Andreas Apr 12 '21 at 10:57
  • 2
    [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Andreas Apr 12 '21 at 10:57
  • 2
    You don't want PHP in the mail. You want the content of variables (e.g. `$example`) in the string. That's part of any PHP tutorial out there -> https://www.php.net/manual/en/language.types.string.php – Andreas Apr 12 '21 at 11:00

1 Answers1

-1

You can't have php in an email, because emails can only have valid html/css code. What you want in your example is something like this:

$txt = '<th>' . $example . '</th>';

An alternative method of doing it would be as follows:

$txt = "<th> $example </th>";

In PHP, double quotation marks allow you to shove variables into the string and it automatically injects them in there. Speed difference is negligible, so you can use whichever fits your needs.