這期內(nèi)容當中小編將會給大家?guī)碛嘘P(guān)使用php怎么對手機號碼進行驗證,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
復(fù)制代碼 代碼如下:
// 手機號驗證
function checkMobileValidity($mobilephone){
$exp = "/^13[0-9]{1}[0-9]{8}$|15[012356789]{1}[0-9]{8}$|18[012356789]{1}[0-9]{8}$|14[57]{1}[0-9]$/";
if(preg_match($exp,$mobilephone)){
return true;
}else{
return false;
}
}
// 手機號碼歸屬地(返回: 如 廣東移動)
function checkMobilePlace($mobilephone){
$url = "/tupian/20230522/mobile_tel_segment.htm
$content = file_get_contents($url);
$p = substr($content, 56, 4);
$mo = substr($content, 81, 4);
return $str = conv2utf8($p).conv2utf8($mo);
}
// 轉(zhuǎn)換字符串編碼為 UTF8
function conv2utf8($text){
return mb_convert_encoding($text,'UTF-8','ASCII,GB2312,GB18030,GBK,UTF-8');
}
上述就是小編為大家分享的使用php怎么對手機號碼進行驗證了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。