开发者

How to replace - with – using php

开发者 https://www.devze.com 2023-01-29 11:27 出处:网络
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 htmlspecialc

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

精彩评论

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

关注公众号