Long story short...
This is the html tag which I want to set the attribute:
echo "<input type='text' name='name' value='".$phpvar."'>";
$phpvar can contain any text and symbols (including quotes and double quotes) in it
How can I properly escape/convert the string to make it display correctly?
Thank you everyone!
EDIT Thank you everyone for helping me out! Ok, if anybody else gets stuck with this, this solved my problem:
- Use double quotes (") surrounding the value of the attribute, because HTML only has an entity code for doubles (") and they won't bug like singles (') do.
- Convert/encode the string with either htmlentities() or htmlspecialchars().