1.不含特殊字符 if(preg_match("/[\'.,:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/",$username)){ //不允许特殊字符 $this->error('不能含有特殊字符!'); }
2.只包含英文和数字 if (! preg_match("/^[0-9a-zA-Z]{4,21}$/",$username)){ $this->error('不能含有特殊字符!'); }
1.不含特殊字符 if(preg_match("/[\'.,:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/",$username)){ //不允许特殊字符 $this->error('不能含有特殊字符!'); }
2.只包含英文和数字 if (! preg_match("/^[0-9a-zA-Z]{4,21}$/",$username)){ $this->error('不能含有特殊字符!'); }