如何检查是否允许用户名如twitter:
Your username can only contain letters, numbers and '_'
我尝试这样的事情,但它不起作用:
if(preg_match("/^[\w.-]*$/", $username)){
// Code
}
答案 0 :(得分:0)
试试这个。
$username = "this_is_username";
$username_control = preg_match("/^[a-z0-9_\d\S.]+$/", $username);
if($username_control === 1){
// success
}else{
// error
}