Escape only single quotes (leave double quotes alone) with htmlspecialchars()
escaping, htmlspecialchars, php
Solution
str_replace("'", "\\'", $string);
There.
Or, use `ENT_QUOTES`
htmlspecialchars($string, ENT_QUOTES);
Problem
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()`?