time().mt_rand(100000,99999).mt_rand(100000,999999)

解决方案 »

  1.   

    时间戳 在秒间是唯一的
    php 提供的最小时间分辨率为 微秒
      

  2.   

    微秒+隨機數function uninum(){
    list($sec, $usec) = explode(' ',microtime());
    return str_replace('.','',sprintf('%f',$sec + $usec).mt_rand(100000,999999));
    }echo uninum();
      

  3.   


    最新版本的 PHP date新增了u,可以显示毫秒。
    其实最安全的唯一数肯定是根据时间来的。1)microtime(true)
    2)  uniqid()
    3) 根据用户IP+浏览器标示头+时间戳
      

  4.   

    也可以用mysql表的自增id作为唯一数