我正在尝试从文本中删除 符号,但我的方法无效。
这是我删除符号的代码。
public static function cleanText($text) {
$textStripped = strip_tags($text); // Strip HTML Tags
$textStripped = html_entity_decode($textStripped); // Clean up things like &
$textStripped = urldecode($textStripped); // Strip out any url-encoded stuff
return $textStripped;
}
页面编码为utf-8。
为什么我有这个符号? 你能详细介绍一下吗?
答案 0 :(得分:1)
这是一个无效的UTF-8字符(可能是某些内容被截断的结果)。您可以使用iconv
public static function cleanText($text) {
$textStripped = strip_tags($text); // Strip HTML Tags
$textStripped = html_entity_decode($textStripped); // Clean up things like &
$textStripped = urldecode($textStripped); // Strip out any url-encoded stuff
return iconv("UTF-8","UTF-8//IGNORE",$textStripped);
}