php 生成唯一编码函数

 

     /**
         * [create_guid 生成guid 全球惟一标识符]
         * @return [type] [description]
         */
         
        public function create_guid(){
           $charid = strtoupper(md5(uniqid(mt_rand(), true)));
           $hyphen = chr(45); // "-"
           $uuid   = substr($charid, 0, 8) . $hyphen
           . substr($charid, 8, 4) . $hyphen
           . substr($charid, 12, 4) . $hyphen
           . substr($charid, 16, 4) . $hyphen
           . substr($charid, 20, 12);
           return $uuid;
       }

  

 

posted on 2020-06-19 16:57  潇潇六月雨  阅读(386)  评论(0编辑  收藏  举报

导航