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

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! :smile:

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

1 Like

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”…

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. \$

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

Sponsor our Newsletter | Privacy Policy | Terms of Service