欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP根據(jù)手機(jī)號判斷運營商(詳細(xì)介紹附代碼)

 更新時間:2018年01月02日 22:36:55   投稿:mdxy-dxy  
這篇文章主要介紹了PHP根據(jù)手機(jī)號判斷運營商,詳細(xì)介紹附代碼,大家可以根據(jù)最新的號段進(jìn)行添加即可,通過正則判斷實現(xiàn),需要的朋友可以參考下

道理很簡單,知道手機(jī)號規(guī)則 進(jìn)行正則判斷就可以

移動:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188

聯(lián)通:130、131、132、152、155、156、185、186

電信:133、153、180、189、(1349衛(wèi)通)

HTML頁面

<!DOCTYPE html>
<html lang="en">
<head>
  <title>手機(jī)號歸屬</title>
</head>
<body>
  <input type="text" onblur="mobile_check($(this).val())" >
</body>
</html>
<script type="text/javascript" src="__ROOT__/Public/admin/lib/jquery/1.9.1/jquery.min.js"></script>  //修改為自己的路徑
<script>
  /*
   移動:134、135、136、137、138、139、150、151、157(TD)、158、159、187、188
   聯(lián)通:130、131、132、152、155、156、185、186
   電信:133、153、180、189、(1349衛(wèi)通)
   */
  var phone = '';
  function mobile_check(phone){
    if(phone.length !== 11){
      alert('未檢測到正確的手機(jī)號碼');
      return false;
    }
    $.ajax({
      url:"__CONTROLLER__/phone_check",
      async:false,
      dataType:'json',
      type:'post',
      data:{phone:phone},
      success:function(msg){
        alert(msg);
      }
    });
  }
</script>

controller控制代碼

/*
  *@param string $phone  手機(jī)號字符串
  *@return 0中國移動,1中國聯(lián)通 2中國電信 3未知
  */
  public function 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}$/"; //移動方面最新答復(fù)
      $isChinaUnion = "/^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/"; //向聯(lián)通微博確認(rèn)并未回復(fù)
      $isChinaTelcom = "/^(?:133|153|177|173|18[019])\d{8}$/"; //1349號段 電信方面沒給出答復(fù),視作不存在
      // $isOtherTelphone = "/^170([059])\\d{7}$/";//其他運營商
      if(preg_match($isChinaMobile, $phone)){
        $this->ajaxReturn('中國移動'); //0
      }else if(preg_match($isChinaUnion, $phone)){
        $this->ajaxReturn('中國聯(lián)通'); //1
      }else if(preg_match($isChinaTelcom, $phone)){
        $this->ajaxReturn('中國電信'); //2
      }else{
        $this->ajaxReturn('未知');   //3
      }
    }

    $this->display();
  }

以上就是全部的實現(xiàn)代碼了,需要的朋友可以參考一下

相關(guān)文章

最新評論