I know there are other ways of of escaping only single quotes (such as this answer), but it appears to me that there should be a way using htmlspecialchars().
According to the manual, it should be some combination of their constants, but based on their explanations, I don't see it.
Is it possible to escape only single quotes, leaving the double quotes alone, with htmlspecialchars()
?
str_replace("'", "\\'", $string);
There.
Or, use ENT_QUOTES
htmlspecialchars($string, ENT_QUOTES);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With