📜  检查值是使用 php 代码示例的电子邮件或手机号码

📅  最后修改于: 2022-03-11 14:54:22.988000             🧑  作者: Mango

代码示例1
if (!(filter_var($_POST["mobile_no"], FILTER_VALIDATE_EMAIL))) {
                $raw_input_length = strlen($mobile_no);
                $phone = preg_replace("/[^\d]/", "", $mobile_no);
                if($raw_input_length == strlen($phone)){
                    if (strlen($phone) !== 10) {
                        $member_mobile_no = '';
                        $show_otp = 0;
                        $error_box = 1;
                        $error = "Please Enter a Valid Mobile Number.";
                        $color = "red";
                    }
                }
                else{
                    $member_mobile_no = '';
                    $show_otp = 0;
                    $error_box = 1;
                    $error = "Please Enter a Valid Email Id.";
                    $color = "red";
                }
        }