php获取微信昵称时如何过滤特殊字符
1个回答
展开全部
用个函数过滤掉特殊塌笑字符
/** * $str 微信昵称 **/ public function filter($str) { if($str){ $name = $str; $name = preg_replace('/\xEE[\x80-\xBF][\旦裤x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]/', '', $name); $name = preg_replace('/xE0[x80-x9F][x80-xBF]‘.‘|xED[xA0-xBF][x80-xBF]/S','?', $name); $return = json_decode(preg_replace("#(\\\ud[0-9a-f]{3})#ie",""团迟含,json_encode($name))); if(!$return){ return $this->jsonName($return); } }else{ $return = ''; } return $return; }
/** * $str 微信昵称 **/ public function filter($str) { if($str){ $name = $str; $name = preg_replace('/\xEE[\x80-\xBF][\旦裤x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]/', '', $name); $name = preg_replace('/xE0[x80-x9F][x80-xBF]‘.‘|xED[xA0-xBF][x80-xBF]/S','?', $name); $return = json_decode(preg_replace("#(\\\ud[0-9a-f]{3})#ie",""团迟含,json_encode($name))); if(!$return){ return $this->jsonName($return); } }else{ $return = ''; } return $return; }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询