前言
最近在忙的一个项目,为了数据安全,不能够使用任何第三方的接口~
号码库 | https://github.com/wangyang0210/Phone-Number-Range
代码
其实就是一个很简单的封装方法,没什么好说的~
/*** 根据号码返回归属地* * @param string $phone 手机号* * @return string $QCellCore 归属地*/ function Get_QCellCore($phone) {$info = Db::name('phones')->alias('p')->join('regions r', 'p.region_id=r.id')->where('p.number ='.substr($phone, 0, 7))->find();$ISP = $info['type'] == 1 ? '移动' : ($info['type'] == 2 ? '联通' : '电信');$area = $info['province'] == $info['city'] ? $info['province'] : $info['province'].$info['city'];return $area.' '.$ISP; }
效果图