一、生成唯一uuid
<?php
function generateUUid($strtoupper = false)
{
$charid = call_user_func($strtoupper ? 'strtoupper' : 'strtolower', md5(uniqid(microtime(true), 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;
}
//结果:37f14a07-cb18-2e54-4e40-da1e2fa0456d
二、生成唯一uid
<?php
function generateUid()
{
return call_user_func('str_shuffle', time());
}
//结果:4067524162
三、 生成唯一uid的正确方法
系统推荐
实践学习php,thinkphp,Redis,vue,uni-app等技术,推荐开源电商系统likeshop,可以借鉴思路,点击阅读原文,或打开地址: