移动互联网时代,手机站是必须的。以下是本人整理的php获取手机浏览器的信息函数,希望对您开发手机站有所帮助。
此收藏的手机信息函数类有取手机号码,浏览器报头信息,取得手机类型,取得手机IP等功能。
代码如下 | 复制代码 |
/** * 类名: mobile * 描述: 手机信息类 * 其他: 偶然 编写 */ class mobile{ /** * 函数名称: getPhoneNumber * 函数功能: 取手机号 * 输入参数: none * 函数返回值: 成功返回号码,失败返回false * 其它说明: 说明 */ function getPhoneNumber(){ if (isset($_SERVER[ 'HTTP_X_NETWORK_INFO '])){ $str1 = $_SERVER[ 'HTTP_X_NETWORK_INFO ']; $getstr1 = preg_replace( '/(.*,)(11[d])(,.*)/i ', '2 ',$str1); Return $getstr1; }elseif (isset($_SERVER[ 'HTTP_X_UP_CALLING_LINE_ID '])){ $getstr2 = $_SERVER[ 'HTTP_X_UP_CALLING_LINE_ID ']; Return $getstr2; }elseif (isset($_SERVER[ 'HTTP_X_UP_SUBNO '])){ $str3 = $_SERVER[ 'HTTP_X_UP_SUBNO ']; $getstr3 = preg_replace( '/(.*)(11[d])(.*)/i ', '2 ',$str3); Return $getstr3; }elseif (isset($_SERVER[ 'DEVICEID '])){ Return $_SERVER[ 'DEVICEID ']; }else{ Return false; } } /** * 函数名称: getHttpHeader * 函数功能: 取头信息 * 输入参数: none * 函数返回值: 成功返回号码,失败返回false * 其它说明: 说明 */ function getHttpHeader(){ $str = ' '; foreach ($_SERVER as $key=> $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; } } ?> |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools
