获取微信昵称时 过滤特殊字符

来源:互联网 发布:淘宝商品市场管理违规 编辑:程序博客网 时间:2024/05/01 06:32
/*** $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;}
0 0
原创粉丝点击