PHP random user name account generation
The difficulty of random generation is how to avoid collision. some people say that md5 and GUID mechanisms are used. of course, they can. but as an account, there are chaos and the number of digits generated is too long. This method only needs to solve the concurrent collision within 1 second, because the fixed header uses the unixtime time, accurate to seconds, more than 1 second, the time of this header must change. This method can also be used to generate random order numbers. The test condition is that 10 thousand random accounts (in milliseconds) are created cyclically, with 0 collisions and 0.1 million with about 0-3 collisions. No internet company will create so many accounts at the same time, so it is enough to cope with the scale of billions of PVS .~~~. Java // automatically generate a random user name // Test, create 10 thousand random accounts cyclically, with 0 collisions, and 0.1 million collisions with about 0-3, which is sufficient to cope with the next billions of PVprivate function genUserNumber () {$ chars = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $ username = ""; for ($ I = 0; $ I <6; $ I ++) {$ username. = $ chars [mt_rand (0, strlen ($ chars)];} return strtoupper (base_convert (time ()-1420070400, 10, 36 )). $ username ;}~~~