PHP based on mobile phone number to determine operator method sharing

Source: Internet
Author: User
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 (); }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.