Home>Article>Backend Development> How to get the mobile phone number and IP address of the mobile phone in php (code example)
The content of this article is about how to obtain the mobile phone number and IP address of the mobile phone in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
$val) { $gstr = str_replace("& ", "& ", $val); $str .= "$key -> " . $gstr . "rn "; } Return $str; } /** * 函数名称: getUA * 函数功能: 取UA * 输入参数: none * 函数返回值: 成功返回号码,失败返回false * 其它说明: 说明 */ function getUA() { if (isset($_SERVER['HTTP_USER_AGENT '])) { Return $_SERVER['HTTP_USER_AGENT ']; } else { Return false; } } /** * 函数名称: getPhoneType * 函数功能: 取得手机类型 * 输入参数: none * 函数返回值: 成功返回string,失败返回false * 其它说明: 说明 */ function getPhoneType() { $ua = $this->getUA(); if ($ua != false) { $str = explode(' ', $ua); Return $str[0]; } else { Return false; } } /** * 函数名称: isOpera * 函数功能: 判断是否是opera * 输入参数: none * 函数返回值: 成功返回string,失败返回false * 其它说明: 说明 */ function isOpera() { $uainfo = $this->getUA(); if (preg_match('/.*Opera.*/i ', $uainfo)) { Return true; } else { Return false; } } /** * 函数名称: isM3gate * 函数功能: 判断是否是m3gate * 输入参数: none * 函数返回值: 成功返回string,失败返回false * 其它说明: 说明 */ function isM3gate() { $uainfo = $this->getUA(); if (preg_match('/M3Gate/i ', $uainfo)) { Return true; } else { Return false; } } /** * 函数名称: getHttpAccept * 函数功能: 取得HA * 输入参数: none * 函数返回值: 成功返回string,失败返回false * 其它说明: 说明 */ function getHttpAccept() { if (isset($_SERVER['HTTP_ACCEPT '])) { Return $_SERVER['HTTP_ACCEPT ']; } else { Return false; } } /** * 函数名称: getIP * 函数功能: 取得手机IP * 输入参数: none * 函数返回值: 成功返回string * 其它说明: 说明 */ function getIP() { $ip = getenv('REMOTE_ADDR '); $ip_ = getenv('HTTP_X_FORWARDED_FOR '); if (($ip_ != " ") && ($ip_ != "unknown ")) { $ip = $ip_; } return $ip; } } ?>
Related recommendations:
PHP obtains the location of the mobile phone number through API, api mobile number
The above is the detailed content of How to get the mobile phone number and IP address of the mobile phone in php (code example). For more information, please follow other related articles on the PHP Chinese website!