ip-the meaning of this regular expression?

Source: Internet
Author: User
Keywords IP php Regular Expression
ipphp Regular Expressions

The whole function is to get the real IP,

 function Real_ip () {Static $realip = NULL;    if ($realip!== NULL) {return $realip;  } if (Isset ($_server)) {if (Isset ($_server[' http_x_forwarded_for ')) {$arr = explode (', ',            $_server[' http_x_forwarded_for ');                /* Take the first non-unknown valid IP string in x-forwarded-for */foreach ($arr as $ip) {$ip = Trim ($IP);                    if ($ip! = ' Unknown ') {$realip = $ip;                Break }}} elseif (Isset ($_server[' http_client_ip ')) {$realip = $_server[' http_cli        Ent_ip ']; } else {if (Isset ($_server[' remote_addr ')) {$realip = $_server[' REMO            Te_addr '];            } else {$realip = ' 0.0.0.0 '; }}}} else {if (getenv (' http_x_forwarded_for ')) {$realip = getenv (' http_x_Forwarded_for ');        } elseif (getenv (' http_client_ip ')) {$realip = getenv (' http_client_ip ');        } else {$realip = getenv (' remote_addr '); }} preg_match ("/[\d\.")    {7,15}/", $realip, $ONLINEIP); $realip =!empty ($onlineip [0])?    $ONLINEIP [0]: ' 0.0.0.0 '; return $realip;}

Preg_match ("/[\d.") {7,15}/", $realip, $ONLINEIP); The regular expression here is a bit confused,
Why do numbers or dots repeat seven to 15 times?

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