我的应用程序中有一个description字段,如果我包含这样的引用:“它会破坏一切。我在整个描述字段中使用了htmlentities(),所以我尝试了htmlspecialchars(),但它也中断了。
在下面的截图中,我发送了一个字符串“我想让这个工作”,并得到了如下的混乱
This is what my string looks like after being run through htmlentities
我以前也遇到过这个问题,但我不知道该怎么解决。

最佳答案

我把代码从

$text = htmlentities( $text, ENT_QUOTES );

致:
$text = htmlentities( $text, ENT_QUOTES, 'utf-8' );

这很奇怪,因为PHP将默认设置列为utf-8。

关于php - PHP htmlentities和htmlspecialchars打破了我的弦,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9705239/

10-12 16:35