醉菜鸟 2021-12-02 09:00:07

php生成唯一识别码uuid

/** 
 * 生成UUID 
 * @param string $prefix 
 * @return string 
 */
function uuid($prefix = ''){    
    $char = strtoupper(md5(uniqid(mt_rand(),true)));   
    $uuid = substr($char,0,8).'-';    
    $uuid .= substr($char,8,4).'-';    
    $uuid .= substr($char,12,4).'-';    
    $uuid .= substr($char,16,4).'-';   
    $uuid .= substr($char,20,12);    
    return $prefix.$uuid;
}
意见反馈