Reputation: 809
I am trying to do a simple convert of single quote ('
) to html entity ('
) but can not figure out why this is not working.
$test = "Bob's House";
echo htmlentities($test,ENT_QUOTES);
echo htmlspecialchars($test,ENT_QUOTES);
Both examples still return: Bob's House
I have tried a combination of flags: ENT_IGNORE, ENT_SUBSTITUTE, etc with no success.
I suspect it has something to do with my charset. If so how do I display my default charset & alter it for this seemingly simple code to work.
Upvotes: 1
Views: 6499
Reputation: 324630
It is working. You are outputting Bob's House
(or similar).
But since you're in a browser, it sees the '
and replaces it with '
.
Want proof? Right-click and View Source.
More proof? echo strlen($test) . " -- " . strlen(htmlentities($test,ENT_QUOTES));
Upvotes: 6