From 51d2d916711ecf0dff368e1a1f10af86811cfc48 Mon Sep 17 00:00:00 2001 From: liuweiwen <529520975@qq.com> Date: Thu, 6 Feb 2020 16:45:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 8 ++++++++ Application/Admin/Controller/ToolController.class.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 7916130e1..cca1ec6e1 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -854,3 +854,11 @@ function convertAmountToCn($num) { return $daxie . '整'; } + +/** + * @param $phone + * @return false|int + */ +function checkPhone($phone) { + return preg_match("/^1[3456789]\d{9}$/",$phone); +} diff --git a/Application/Admin/Controller/ToolController.class.php b/Application/Admin/Controller/ToolController.class.php index d5aee52fc..056c6c1ec 100644 --- a/Application/Admin/Controller/ToolController.class.php +++ b/Application/Admin/Controller/ToolController.class.php @@ -726,7 +726,7 @@ class ToolController extends ThinkController { $this->error('公司名称已存在'); } - if(!preg_match("/^1[358][0-9]{9}$/u",I('link_phone'))) { + if(!checkPhone(I('link_phone'))) { $this->error('联系电话格式不正确'); } $res2 = $model->where(['link_phone' => I('link_phone')])->getField('id'); @@ -798,7 +798,7 @@ class ToolController extends ThinkController { $this->error('公司名称已存在'); } - if(!preg_match("/^1[358][0-9]{9}$/u",I('link_phone'))) { + if(!checkPhone(I('link_phone'))) { $this->error('联系电话格式不正确'); } $res2 = $model->where([