This article mainly introduces PHP according to mobile phone number judgment operator, detailed introduction of the code, we can add according to the latest number segment, through regular judgment to achieve, the need for friends can refer to, hope to help everyone.
The reason is very simple, know the cell phone number rules to make a regular judgment can
Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188
Unicom: 130, 131, 132, 152, 155, 156, 185, 186
Telecom: 133, 153, 180, 189, (1349 Wei Tong)
HTML page
<! DOCTYPE html>
Controller control Code
/* * @param string $phone phone number * @return 0 China Mobile, 1 unicom 2 Chinese Telecom 3 Unknown */public functio n Phone_check () {if (is_post) {$phone = I (' phone '); $isChinaMobile = "/^134[0-8]\d{7}$|^ (?: 13[5-9]|147|15[0-27-9]|178|18[2-478]) \d{8}$/"; Latest Mobile Response $isChinaUnion = "/^ (?: 13[0-2]|145|15[56]|176|18[56]) \d{8}$/"; To the Unicom Weibo confirmation did not reply $isChinaTelcom = "/^ (?: 133|153|177|173|18[019]) \d{8}$/"; No answer is given in paragraph 1349th telecommunications, as does not exist//$isOtherTelphone = "/^170 ([059]) \\d{7}$/";//other carrier if (Preg_match ($isChinaMobile, $pho NE) {$this->ajaxreturn (' China Mobile ');//0}else if (Preg_match ($isChinaUnion, $phone)) {$this->ajaxretu RN (' China Unicom '); 1}else if (Preg_match ($isChinaTelcom, $phone)) {$this->ajaxreturn (' China Telecom ');//2}else{$this-& Gt;ajaxreturn (' unknown '); 3}} $this->display (); }