How PHP obtains mobile phone number and IP address (code example)

Source: Internet
Author: User

This article brings you the content is about how to get the mobile phone number and IP address of PHP, there is a certain reference value, the need for friends can refer to, I hope to help you.

<?php/** * Created by Phpstorm.    * User:liubao * DATE:2018/8/30 * time:16:21 *//** * class Name: Mobile * Description: Mobile Information class * Other: Accidental writing */class mobile{   /** * Function Name: Getphonenumber * Function function: Take phone number * input parameter: none * function return value: Successful return number, failure return false *  Additional 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, failed 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 function: Get phone type * input parameter: none * function return Value: String returned successfully, failed to return FAL        SE * Other Instructions: Description */function 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, failed to return Fals        E * Other Instructions: Description */function 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, failed to return FA        LSE * OTHER INSTRUCTIONS: Description */function ism3gate () {$uainfo = $this->getua ();        if (Preg_match ('/m3gate/i ', $uainfo)) {Return true;        } else {Return false; }}/** * Function name: Gethttpaccept * function function: Get ha * input parameter: none * function return Value: String returned successfully, failed to return Fals E * Other Instructions: Description */function gethttpaccept () {if (Isset ($_server[' http_accept ')) {REturn $_server[' http_accept '];        } else {Return false;   }}/** * Function name: GetIP * Function function: Get phone IP * input parameter: none * function return Value: String * Other instructions successfully returned:        Description */function GetIP () {$ip = getenv (' remote_addr ');        $ip _ = getenv (' http_x_forwarded_for ');        if ($ip _! = "") && ($ip _! = "Unknown")) {$ip = $ip _;    } return $IP; }}?>
Related Article

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.