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.
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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.