#生成不重复Id
public function getOrderId($prefix = 'DD')
{
return $prefix . (strtotime(date('YmdHis', time()))) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999));
}
#生APP用户token
public function getToken()
{
//strtoupper转换成全大写的
$charid = strtoupper(md5(uniqid(mt_rand(), true)));
return substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4) . substr($charid, 20, 12);
}
```
PHP高并发下生成唯一的不重复的订单id,以及生成不重复的用户token
最新推荐文章于 2023-10-01 17:31:02 发布