首页 >php教程 >PHP源码 >获取国内随机IP地址

获取国内随机IP地址

PHP中文网
PHP中文网原创
2016-05-25 17:05:521777浏览

[PHP]代码  

<?php

/**
 * 获取国内随机IP地址
 * 注:适用于32位操作系统
 */
function rand_ip(){
        $ip_long = array(
            array(&#39;607649792&#39;, &#39;608174079&#39;), //36.56.0.0-36.63.255.255
            array(&#39;1038614528&#39;, &#39;1039007743&#39;), //61.232.0.0-61.237.255.255
            array(&#39;1783627776&#39;, &#39;1784676351&#39;), //106.80.0.0-106.95.255.255
            array(&#39;2035023872&#39;, &#39;2035154943&#39;), //121.76.0.0-121.77.255.255
            array(&#39;2078801920&#39;, &#39;2079064063&#39;), //123.232.0.0-123.235.255.255
            array(&#39;-1950089216&#39;, &#39;-1948778497&#39;), //139.196.0.0-139.215.255.255
            array(&#39;-1425539072&#39;, &#39;-1425014785&#39;), //171.8.0.0-171.15.255.255
            array(&#39;-1236271104&#39;, &#39;-1235419137&#39;), //182.80.0.0-182.92.255.255
            array(&#39;-770113536&#39;, &#39;-768606209&#39;), //210.25.0.0-210.47.255.255
            array(&#39;-569376768&#39;, &#39;-564133889&#39;), //222.16.0.0-222.95.255.255
        );
		$rand_key = mt_rand(0, 9);
		$ip       = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
        return $ip;
}

                   

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn