PHP Get phone-related information

Source: Internet
Author: User

The PHP operation class implements the acquisition of mobile phone number
Phone head information, take UA, get phone type, judge whether it is opera, judge whether it is m3gate, get ha, get mobile IP
The code is as follows:

<?php
/**
* @desc Mobile phone operation to get information about mobile phone
* @since
*/
Class Mobile {
/**
* Function Name: Getphonenumber
* Function function: Take phone number
* Input Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
Public Function Getphonenumber () {
if (Isset ($_server[' Http_x_network_info ')) {
$str 1 = $_server[' http_x_network_info ');
$getstr 1 = preg_replace ('/(. *,) (11[d]) (,. *)/I ', "", $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 ', "", $str 3);
Return $GETSTR 3;
}
ElseIf (Isset ($_server[' DEVICEID ')) {
Return $_server[' DEVICEID '];
}
else {
Return false;
}
}

/**
* Function Name: Gethttpheader
* Function Function: Take header information
* Input Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
Public 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 Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
Public Function Getua () {
if (Isset ($_server[' http_user_agent ')) {
Return $_server[' http_user_agent '];
}
else {
Return false;
}
}

/**
* Function Name: Getphonetype
* Function function: Get phone type
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
Public Function Getphonetype () {
$ua = $this->getua ();
if ($ua!=false) {
$str = Explode ("", $ua);
Return $str [0];
}
else {
Return false;
}
}

/**
* Function Name: Isopera
* Function Function: Judge whether it is opera
* Input parameters: none www.knowsky.com
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
Public Function Isopera () {
$uainfo = $this->getua ();
if (Preg_match ('/.*opera.*/i ', $uainfo)) {
Return true;
}
else {
Return false;
}
}

/**
* Function Name: ism3gate
* Function Function: Judge whether it is m3gate
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
Public Function ism3gate () {
$uainfo = $this->getua ();
if (Preg_match ('/m3gate/i ', $uainfo)) {
Return true;
}
else {
Return false;
}
}

/**
* Function Name: gethttpaccept
* Function function: Get ha
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
Public Function gethttpaccept () {
if (Isset ($_server[' http_accept ')) {
Return $_server[' http_accept '];
}
else {
Return false;
}
}

/**
* Function Name: GetIP
* Function function: Get phone IP
* Input Parameters: None
* Function return Value: String returned successfully
* Other Instructions: description
*/
Public Function GetIP () {
$ip =getenv (' remote_addr ');
$ip _ = getenv (' http_x_forwarded_for ');
if (($ip _! = "") && ($ip _! = "Unknown")) {
$ip = $ip _;
}
return $IP;
}
}

?>

PHP Get phone-related information

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.