htmlspecialchars使用不是英语的单词

时间:2016-02-20 19:21:59

标签: php htmlspecialchars

我想阻止阅读特殊字符,例如如果$ txt =“<b>hello</b>”,我想用粗体打印“<b>hello</b>"”而不是“你好”。 所以我添加了行$txt=htmlspecialchars($txt, ENT_QUOTES, 'UTF-8');。它解决了这个问题,但现在如果我输入不是英文的单词,例如שלום(希伯来语单词),它给了我&#1513;&#1500;&#1493;&#1501;。我该如何解决?这是我的代码:

$txt=$_POST['post_txt'];
$txt=htmlspecialchars($txt, ENT_QUOTES, 'UTF-8');/prevent xss
$txt=nl2br($txt);//make it with line breaks

1 个答案:

答案 0 :(得分:-1)

我不确定希伯来语是否受到支持,但这些网站可能会解决您的问题。此外,应使用htmlentities()

http://php.net/manual/en/function.htmlspecialchars.php

http://www.techiecorner.com/129/php-how-to-convert-iso-character-htmlentities-to-utf-8/

祝你好运!