
正文
PHP生成 uuid
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
// 生成UUID,并去掉分割符
function guid() {
if (function_exists('com_create_guid')){
$uuid = com_create_guid();
}else{
mt_srand((double)microtime()*);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr();// "-"
$uuid = chr()// "{"
.substr($charid, , ).$hyphen
.substr($charid, , ).$hyphen
.substr($charid,, ).$hyphen
.substr($charid,, ).$hyphen
.substr($charid,,)
.chr();// "}"
}
$uuid = str_replace(array('-', '{', '}'), '', $uuid);
return $uuid;
}







