php 判斷手機號運營商


/*
     移動:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188
     聯通:130、131、132、152、155、156、185、186
     電信:133、153、180、189、(1349衛通)
     */
    /**
     *   手機服務商函數 getphonetype
     *@author by @tianxiao
     *@param  string  $phone   手機號字符串
     *@return  unsignedint   0中國移動,1中國聯通  2中國電信  3未知
     **/
    function getphonetype($phone){
        $phone = trim($phone);
        $isChinaMobile = "/^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/"; //移動方面最新答復
        $isChinaUnion = "/^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/"; //向聯通微博確認並未回復
        $isChinaTelcom = "/^(?:133|153|177|173|18[019])\d{8}$/"; //1349號段 電信方面沒給出答復,視作不存在
        // $isOtherTelphone = "/^170([059])\\d{7}$/";//其他運營商
        if(preg_match($isChinaMobile, $phone)){
            return 0;
        }elseif(preg_match($isChinaUnion, $phone)){
            return 1;
        }elseif(preg_match($isChinaTelcom, $phone)){
            return 2;
        }else{
            return 3;
        }
    }

 

/* 移動:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188 聯通:130、131、132、152、155、156、185、186 電信:133、153、180、189、(1349衛通) *//** *   手機服務商函數 getphonetype *@author by @tianxiao *@param  string  $phone   手機號字符串 *@return  unsignedint   0中國移動,1中國聯通  2中國電信  3未知 **/function getphonetype($phone){    $phone = trim($phone);    $isChinaMobile = "/^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/"; //移動方面最新答復    $isChinaUnion = "/^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/"; //向聯通微博確認並未回復    $isChinaTelcom = "/^(?:133|153|177|173|18[019])\d{8}$/"; //1349號段 電信方面沒給出答復,視作不存在    // $isOtherTelphone = "/^170([059])\\d{7}$/";//其他運營商    if(preg_match($isChinaMobile, $phone)){        return 0;    }elseif(preg_match($isChinaUnion, $phone)){        return 1;    }elseif(preg_match($isChinaTelcom, $phone)){        return 2;    }else{        return 3;    }}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM