0

I know it has been discussed many times, but I can not find any solution to this problem.

I have a PHP file with the following code

if (file_exists("email.html")) {
        $message = file_get_contents("email.html");
    } else {
        echo "No email.html file present";
        return;
    }

in my file email.html I have something like:

  <p>Hello %recipient.UserName%, you receive this Email because you signed up at our site.</p>

variable $UserName is declared in the php file (in array).

When looking at the html file output, I see the variable is not correctly passed and stays as % %

Any suggestion? thanks!

2
  • change this to <?php echo %recipient.UserName%; ?> Commented Jun 8, 2017 at 11:28
  • file_get_contents() just gets the contents, it does not parse anything so if you don't do that yourself after getting it, it will remain the same. Commented Jun 8, 2017 at 11:33

1 Answer 1

1

If you don't have a template engine you can't do it with % % OR other symbol . for your question simple approach is to use it like this :

  <p>Hello <? = $recipient['UserName'] ?>, you receive this Email because you signed up at our site.</p>

EDIT

you have to include the file

ob_start();
include "email.html";
$message = ob_get_clean();
Sign up to request clarification or add additional context in comments.

1 Comment

Yes right a forgot about this i will edit my answer thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.