# Using an external php or html file (template) to fill a var?

**URL:** <https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346>\
**Category:** Beginners - Learning PHP\
**Created:** [March 19, 2023, 12:04am UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346 "2023-03-19T00:04:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zoldos](https://www.phphelp.com/user_avatar/www.phphelp.com/zoldos/32/4221_2.png) [@zoldos](https://www.phphelp.com/u/zoldos)\
**Post date:** [March 19, 2023, 12:04am UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346/1 "2023-03-19T00:04:36Z")

</div>

I have a line like this in my code:

```
$message = "Thanks for your request!";

```

The full var is large and contains some special characters that are not rendering correctly. So can I replace all that with just a single external php or html file? Like a template? I’m not sure at all how to do that.

Any tips would be greatly appreciated! 😄

---

<div class="post-metadata">

**Author:** ![Strider64](https://www.phphelp.com/user_avatar/www.phphelp.com/strider64/32/3161_2.png) [@Strider64](https://www.phphelp.com/u/Strider64)\
**Post date:** [March 19, 2023, 11:33am UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346/2 "2023-03-19T11:33:51Z")

</div>

Smarty and Twig are PHP templates that might do the trick? I assuming you thinking of security?

---

<div class="post-metadata">

**Author:** ![zoldos](https://www.phphelp.com/user_avatar/www.phphelp.com/zoldos/32/4221_2.png) [@zoldos](https://www.phphelp.com/u/zoldos)\
**Post date:** [March 19, 2023, 1:28pm UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346/3 "2023-03-19T13:28:17Z")

</div>

I’ve used Smarty before and liked it. As for security, that would probably be overkill. My code is a single PHP file that collects an e-mail and then sends a message to the user with further info. The specific issue is that in this e-mail (which is produced by echo " "; inside the PHP) there is a “’$”, but it is NOT a var, but rather to display my CashApp address. This starts with $. But every time the echo message e-mail is generated, it is interpreted as a var and doesn’t display.

I’ve tried several things, using ASCII, etc. Just can’t get it to work. I know it’s silly, but I can’t figure it out, hence the external html or PHP “template”…

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [March 19, 2023, 2:28pm UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346/4 "2023-03-19T14:28:44Z")

</div>

> [@zoldos](#):
>
> a “’$”, but it is NOT a var,

If you had initially stated what problem you were trying to solve, you could have directly gotten a solution. Escape the $ with a `\`, e.g. `\$`

---

<div class="post-metadata">

**Author:** ![zoldos](https://www.phphelp.com/user_avatar/www.phphelp.com/zoldos/32/4221_2.png) [@zoldos](https://www.phphelp.com/u/zoldos)\
**Post date:** [March 19, 2023, 2:48pm UTC](https://www.phphelp.com/t/using-an-external-php-or-html-file-template-to-fill-a-var/35346/5 "2023-03-19T14:48:45Z")

</div>

I apologize. I guess I was overthinking it. It worked, thank you very much! 🙂
