简单判断登陆用户账号是email,还是手机号,还是账户的方法

精简实用5年前 (2020-10-09)8490

简单判断登陆用户账号是email,还是手机号,还是账户的方法

$check_email = preg_match("/[a-z0-9_\-\.]+@([a-z0-9_\-]+?\.)+[a-z]{2,3}/i", $username, $match_email);
$check_mobile = preg_match("/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/", $username, $match_mobile);
if ($check_email) {
    $email = $username;
    $username = '';
    $mobile = '';
    $type = 2;
} elseif ($check_mobile) {
    $mobile = $username;
    $username = '';
    $email = '';
    $type = 3;
} else {
    $mobile = '';
    $email = '';
    $type = 1;
}

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。