ricmetal Posted September 1, 2013 Share Posted September 1, 2013 hi yall how can i escape php variables inside a html attribute, being echoed with php? like follows: echo "<img title=' " . $ls_cb_title . " '>"; Link to comment https://forums.phpfreaks.com/topic/281748-escaping-variables/ Share on other sites More sharing options...
requinix Posted September 1, 2013 Share Posted September 1, 2013 htmlspecialchars or htmlentities. Be aware of the ENT_QUOTES setting (apostrophes are not encoded by default) and the character set parameter (as they both assume ISO 8859-1 unless told otherwise). Consider writing your own function that calls either using the correct arguments - that way you don't have to remember to do that yourself every time. Link to comment https://forums.phpfreaks.com/topic/281748-escaping-variables/#findComment-1447648 Share on other sites More sharing options...
ricmetal Posted September 1, 2013 Author Share Posted September 1, 2013 cool. thanks for that. Link to comment https://forums.phpfreaks.com/topic/281748-escaping-variables/#findComment-1447682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.