37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
namespace App\Admin\Extensions;
|
|
|
|
/**
|
|
* 校验手机号
|
|
*/
|
|
class mobile
|
|
{
|
|
|
|
public function phoneOperator()
|
|
{
|
|
$isPhone = "/^1[3-9]\d{9}$/"; //先判断正确手机号格式
|
|
|
|
if (preg_match($isPhone, $phone)) {
|
|
|
|
$isChinaMobile = "/^134[0-9]\d{7}$|^1703\d{7}$|^170[5-6]\d{7}$|^(?:13[5-9]|147|148|15[0-27-9]|178|18[2-478]|198)\d{8}$/"; //
|
|
$isChinaUnion = "/^1704\d{7}$|^170[7-9]\d{7}$|^171[0-9]\d{7}$|^(?:13[0-2]|145|15[56]|166|140|175|176|18[56])\d{8}$/"; //
|
|
$isChinaTelcom = "/^(?:133|153|169|177|173|174|170|179|18[019]|199)\d{8}$|^170[0-2]\d{7}$/"; //
|
|
|
|
if (preg_match($isChinaMobile, $phone)) {
|
|
return 'mobile'; //中国移动
|
|
} else if (preg_match($isChinaUnion, $phone)) {
|
|
return 'unicom'; //中国联通
|
|
} else if (preg_match($isChinaTelcom, $phone)) {
|
|
return 'telecom'; //中国电信
|
|
} else {
|
|
return 0;
|
|
}
|
|
|
|
} else {
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
}
|