/**
* UUID不重复号,指定前缀
* @param null $prefix
* @return string
*/
function generateReadableUUID($prefix = null)
{
mt_srand((double)microtime() * 10000);
$charId = strtoupper(md5(uniqid(rand() , true)));
$hyphen = chr(45);//"-"
$uuid = chr(123)//"{"
.substr($charId,0,8).$hyphen
.substr($charId,8,4).$hyphen
.substr($charId,12,4).$hyphen
.substr($charId,16,4).$hyphen
.substr($charId,20,12)
.chr(125);//"}"
$getUUID = strtoupper(str_replace("-","",$uuid));
$generateReadableUUID = $prefix . date("ymdHis") . sprintf('%03d' , rand(0 , 999)) . substr($getUUID , 4 , 4);
return $generateReadableUUID;
}
生成唯一不重复号,可以指定前缀 UUID号生成
最新推荐文章于 2025-04-02 09:46:20 发布