Don't go in the database check
Reply content:
Don't go in the database check
function makeCode($t) { $time = $t.mt_rand(10,99); // 要是觉得不够可以加上线程ID等。 $ce = $time[9]; $xy = array(); $xy[0] = array('A','F','D','X','G','H','K','U','P','Y','W','P'); $xy[1] = array('R','G','H','P','X','D','Y','U','K','F','S','Z'); // ... 不重复的序列即可 $xy[9] = array('S','K','T','U','E','Q','V','G','R','X','C','J'); $rb = ''; for ($i = 12;$i--;) { $rb .= $xy[$ce][$time[$i]]; } return $rb;}makecode(time())
For 绝对唯一
speaking please useUUID
For example, you are using a Linux system that can
echo file_get_contents('/proc/sys/kernel/random/uuid');// 输出: 6c509fc7-328b-4d82-9af8-60c44e7b84b4
When you get a unique string like this, you can do whatever you want to do with it, such as intercepting the length you need.
PHP generates UUID in a number of ways, it is simple to use, also recommended a class library link
If it is a general recommendation code actually does not need to make very complicated, unless you have a lot of user volume. If it's a general company, I think it's enough.
echo bin2hex(openssl_random_pseudo_bytes(16));// 输出: 5a8a80e06ffe44fd0a6931707a26f0cc
Likewise, you are free to intercept
http://hashids.org/
Add a check code to it.