php 验证手机号、邮箱
            2019-08-23            PHP             2823         
                常用的正则验证规则
if (isset($post['email'])) {
    if (!preg_match("/^\w+\.?\w*@\w+\.\w*\.?[a-z]{2,}$/", $post['email'])) {
        $this->error('邮箱格式不对');
    }
    $data['email'] = $post['email'];
}
if (isset($post['mobile'])) {
    if (!preg_match("/1\d{10}/", $post['mobile'])) {
        $this->error('手机号格式不对');
    }
    $data['mobile'] = $post['mobile'];
} 很赞哦! (0)
                                                         相关文章
文章评论
- 
- 
- 
                                        0条评论                                    
                 
         
              