dd

史上产生位数最短的随机唯一ID php函数

jerry thinkphp 2015年11月18日 收藏
产生位数最短的随机唯一ID php函数.可用于我们日常手机里收到的超连接如:XXXXXX详情点击:http://xxxx.com/user.php/m/o/i/n.bcuf1b中的bcuf1b
产生位数最短的随机唯一ID php函数.可用于我们日常手机里收到的短信超连接。如:XXXXXX详情点击:http://xxxx.com/user.php/m/o/i/n.bcuf1b中的bcuf1b
<?php
    //Author:铜豌豆
    //QQ:309581329
    //Email:bestphper@126.com
    //http://gongwen.sinaapp.com
    function getRandOnlyId() {
        //新时间截定义,基于世界未日2012-12-21的时间戳。
        $endtime=1356019200;//2012-12-21时间戳
        $curtime=time();//当前时间戳
        $newtime=$curtime-$endtime;//新时间戳
        $rand=rand(0,99);//两位随机
        $all=$rand.$newtime;
        $onlyid=base_convert($all,10,36);//把10进制转为36进制的唯一ID
        return $onlyid;
    }
    //得到随机唯一id
    echo getRandOnlyId();
?>
dd