diff --git a/application/common.php b/application/common.php index 519a6707..08eae7aa 100644 --- a/application/common.php +++ b/application/common.php @@ -57,4 +57,16 @@ function makePathToUrl($path,$type = 2) return trim(str_replace(DS, '/',UPLOAD_PATH.$path),'.'); }else return ''; +} +// 过滤掉emoji表情 +function filterEmoji($str) +{ + $str = preg_replace_callback( //执行一个正则表达式搜索并且使用一个回调进行替换 + '/./u', + function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, + $str); + + return $str; } \ No newline at end of file