Php reads the class library of the mobile client browser

Source: Internet
Author: User

The functions of this favorite mobile phone information include getting mobile phone numbers, browser header information, obtaining mobile phone types, and obtaining mobile phone IP addresses.

The code is as follows: Copy code
<? Php
/**
* Class name: mobile
* Description: mobile phone information.
* Others: accidental writing
*/

Class mobile {
/**
* Function name: getPhoneNumber
* Function: obtains the mobile phone number.
* Input parameter: none
* Function return value: the number is returned successfully. If the function fails, false is returned.
* Other instructions: Description
*/
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;
}
}

/**
* Function name: getHttpHeader
* Function: obtains the header information.
* Input parameter: none
* Function return value: the number is returned successfully. If the function fails, false is returned.
* Other instructions: Description
*/
Function getHttpHeader (){
$ Str = '';
Foreach ($ _ SERVER as $ key => $ val ){
$ Gstr = str_replace ("&", "&", $ val );
$ Str. = "$ key->". $ gstr. "rn ";
}
Return $ str;
}

/**
* Function name: getUA
* Function: UA
* Input parameter: none
* Function return value: the number is returned successfully. If the function fails, false is returned.
* Other instructions: Description
*/
Function getUA (){
If (isset ($ _ SERVER ['http _ USER_AGENT ']) {
Return $ _ SERVER ['http _ USER_AGENT '];
} Else {
Return false;
}
}

/**
* Function name: getPhoneType
* Function: obtains the mobile phone type.
* Input parameter: none
* Function return value: string is returned for success, and false is returned for failure.
* Other instructions: Description
*/
Function getPhoneType (){
$ Ua = $ this-> getUA ();
If ($ ua! = False ){
$ Str = explode ('', $ ua );
Return $ str [0];
} Else {
Return false;
}
}

/**
* Function name: isOpera
* Function: determines whether it is opera.
* Input parameter: none
* Function return value: string is returned for success, and false is returned for failure.
* Other instructions: Description
*/
Function isOpera (){
$ Uainfo = $ this-> getUA ();
If (preg_match ('/. * Opera. */I', $ uainfo )){
Return true;
} Else {
Return false;
}
}

/**
* Function name: ismreceivate
* Function: determines whether it is mshortate.
* Input parameter: none
* Function return value: string is returned for success, and false is returned for failure.
* Other instructions: Description
*/
Function ismreceivate (){
$ Uainfo = $ this-> getUA ();
If (preg_match ('/mshortate/I', $ uainfo )){
Return true;
} Else {
Return false;
}
}

/**
* Function name: getHttpAccept
* Function: obtain the HA
* Input parameter: none
* Function return value: string is returned for success, and false is returned for failure.
* Other instructions: Description
*/
Function getHttpAccept (){
If (isset ($ _ SERVER ['http _ ACCEPT ']) {
Return $ _ SERVER ['http _ ACCEPT '];
} Else {
Return false;
}
}

/**
* Function name: getIP
* Function: obtain the mobile IP address.
* Input parameter: none
* Function return value: string is returned successfully.
* Other instructions: Description
*/
Function getIP (){
$ Ip = getenv ('remote _ ADDR ');
$ Ip _ = getenv ('http _ X_FORWARDED_FOR ');
If ($ ip _! = "") & ($ Ip _! = "Unknown ")){
$ Ip = $ ip _;
}
Return $ ip;
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.