我在我的文本字段中使用HTML净化器(Yii2)。HTML净化器转换和 - > &
原需要保存“&”,但净化器转换为“& amp”;
我不想在净化器后使用str_replace
。
你能帮我配置吗?
我的配置:
['name'],
'filter',
'filter' => function($value) {
return HtmlPurifier::process($value, [
'HTML.SafeObject' => true,
'HTML.SafeEmbed' => true,
'Core.EscapeNonASCIICharacters' => true,
'Core.Encoding' => 'UTF-8'
]);
}
UPD:
文字的例子,我想要什么净化: “公司名称&有限公司”
为什么你需要保存'&'在原来的?你需要净化的环境是什么? – pinkgothic
(如果您想知道我为什么要求,请参阅http://stackoverflow.com/a/37641037/245790和http://stackoverflow.com/a/26128263/245790。) – pinkgothic
为什么? HTML允许'&'在空格后面显示为文字字符。 – Quentin