PHP How to read the class sample code of the mobile client browser

Source: Internet
Author: User
This article mainly introduces the PHP implementation of reading mobile phone client browser class, can achieve the mobile phone number, browser header information, access to mobile phone type, access to mobile phone IP and other functions, the need for friends can refer to the next

This article describes the PHP implementation of reading the phone client browser class. Share to everyone for your reference. The specific analysis is as follows:

Here the mobile phone information function class has taken mobile phone number, browser header information, access to mobile phone type, access to mobile phone IP and other functions.

The code is as follows:

<?php/** * Class Name: Mobile * Description: Mobile Information class * Other: Accidental writing */class mobile{/** * Function Name: Getphonenumber * Function function: Phone number * Input parameter: none * function return value: Successful return number, failure return false * Other Instructions: Description */function Getphonenumber () {if (Isset ($_server [' Http_x_network_info '])) {$str 1 = $_server[' Http_x_network_info '); $getstr 1 = preg_replace ('/(. *,) (11[d]) (,. *)/I ', ' 2 ', $str 1); Return $getstr 1; }elseif (Isset ($_server[' http_x_up_calling_line_id ')) {$getstr 2 = $_server[' http_x_up_calling_line_id ']; Return $GETSTR 2; }elseif (Isset ($_server[' http_x_up_subno ')) {$str 3 = $_server[' http_x_up_subno '); $getstr 3 = Preg_replace ( '/(. *) (11[d]) (. *)/I ', ' 2 ', $str 3); Return $GETSTR 3; }elseif (Isset ($_server[' DEVICEID ')) {Return $_server[' DEVICEID '];} Else{Return false;}}   /** * Function Name: Gethttpheader * Function Function: header information * input parameter: none * function return value: Successful return number, failure return false * 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 function: Take UA * input parameter: none * function return value: Successful return number, failure return false * Other Instructions: Description */function Getua () {if (Isset ($_server[' http_user_agent ')) {Return $_server[' http_user_agent '];} Else{Return false;}} /** * Function Name: Getphonetype * Function: Get phone type * input parameter: none * function return Value: String returned successfully, failure returned false * Other Instructions: Description */funct Ion Getphonetype () {$ua = $this, Getua (), if ($ua!=false) {$str = Explode (", $ua); Return $str [0]; }else{Return false;}} /** * Function Name: Isopera * Function: Determine if it is opera * input parameter: none * function return Value: String returned successfully, failure returned false * Other Instructions: Description */FUNCTI On Isopera () {$uainfo = $this, Getua (), if (Preg_match ('/.*opera.*/i ', $uainfo)) {Return true;} Else{Return false;}}   /** * Function Name: Ism3gate * Function function: Determine if it is m3gate * input parameter: none * function return Value: String returned successfully, failure returns false * other instructions:Description */function ism3gate () {$uainfo = $this, Getua (), if (Preg_match ('/m3gate/i ', $uainfo)) {Return true;} Else{Return false;}} /** * Function Name: gethttpaccept * Function: Get ha * input parameter: none * function return Value: String returned successfully, failure returned false * Other Instructions: Description */FUNCTI On gethttpaccept () {if (Isset ($_server[' http_accept ')) {Return $_server[' http_accept '];} Else{Return false;}} /** * Function Name: GetIP * Function: Get phone IP * input parameter: none * function return value: String not returned successfully * Other Description: Description */function GetIP () {$i P=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.