Home  >  Article  >  php教程  >  获取国内随机IP地址

获取国内随机IP地址

PHP中文网
PHP中文网Original
2016-05-25 17:05:521754browse

[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;
}

                   

                   

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:memcache队列类Next article:PHP中文首字母转拼音