简体   繁体   中英

How to save string with variables to database?

I wish to save html email to database. I've prepared my string witch contains html code and some variables like:

$name = "Tom";
$msg = '<p>how are you '.$name.' ?</p>';
$testmsg = htmlentities($msg, ENT_QUOTES, "UTF-8");

...than save it with PDO to database.

Problem is that when I'm using htmlentities function $testmsg becomes empty...

What should i do to save this string with many variables and call htmlentities?

The php file that is containing those:

$name = "Tom";
$msg = '<p>how are you '.$name.' ?</p>';
$testmsg = htmlentities($msg, ENT_QUOTES, "UTF-8");

need to be saved in UTF8. I've saved it in ANSI by mistake and htmlentities function cleared whole string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM