php手机、邮箱规则验证

    function checkPhone($phone)
    {
        $check = '/^(1(([3456789][0-9])|(47)))\d{8}$/';
        if (preg_match($check, $phone)) {
            return true;
        } else {
            return false;
        }
    }

 

function checkEmail($email)
{
    // Create the syntactical validation regular expression
    $regexp = "/^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/";
    if (preg_match($regexp, $email)) {
        return true;
    } else {
        return false;
    }
}

 

posted @ 2020-10-21 09:56  一颗糊涂淡  阅读(144)  评论(0编辑  收藏  举报