Unable to get IP address PHP method for obtaining an accurate IP address

Source: Internet
Author: User
Tags get ip
//Get IP addressfunction GetIP () {if(getenv(' Http_client_ip ') && strcasecmp (getenv(' Http_client_ip '),' Unknown ')) {$thisip=getenv(' Http_client_ip '); } elseif (getenv(' Http_x_forwarded_for ') && strcasecmp (getenv(' Http_x_forwarded_for '),' Unknown ')) {$thisip=getenv(' Http_x_forwarded_for '); } elseif (getenv(' REMOTE_ADDR ') && strcasecmp (getenv(' REMOTE_ADDR '),' Unknown ')) {$thisip=getenv(' REMOTE_ADDR '); } ElseIf (Isset ($_server[' REMOTE_ADDR ']) &&$_server[' REMOTE_ADDR '] && strcasecmp ($_server[' REMOTE_ADDR '],' Unknown ')) {$thisip=$_server[' REMOTE_ADDR ']; } preg_match ("/[\d\." {7,15}/",$thisip,$thisips);$thisip=$thisips[0] ?$thisips[0] :' Unknown ';return$thisip;}

It's been tested. Can get to the real IP address! Tcp/ipv4

You can just put it in the code. You're welcome. Please call me ' Lei Feng '

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the inability to obtain the IP address of PHP to obtain an accurate IP address, including the inability to obtain the IP address of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.