Table of Contents
php实现读取手机客户端浏览器的类,php客户端
Home php教程 php手册 php实现读取手机客户端浏览器的类,php客户端

php实现读取手机客户端浏览器的类,php客户端

Jun 13, 2016 am 09:17 AM
php cell phone kind

php实现读取手机客户端浏览器的类,php客户端

本文实例讲述了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;
}
}
?>

希望本文所述对大家的php程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles