开发者

How to replace - with – using php

How do i replace - with – using php htmlspecialchars()

$content = $_POST['content'];开发者_开发问答


You don't, - is not a special character and as such will not be touched by htmlspecialchars(). And - is not even same as – (- vs. –).

You can use str_replace() if you want to:

$content = str_replace('-', '–', $_POST['content']);


htmlentities() will convert to – (and take care of any other entities as well).

Just make sure you specify the correct character set, e.g.:

echo htmlentities($string, ENT_QUOTES, 'UTF-8');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜