1. Generate a unique ID
Uniqid ();//without prefix, the generated string is 13 bits, according to the current subtle timestamp
2. Random functions
/**
* Generate a random string of the specified number of digits
*
* @param int $len random string length
* @param bool $include _number is allowed to contain numbers
*
*/
public static function make_rand_string ($len, $include _number = False) {
$string _list = Array (' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' J ', ' K ', ' L ', ' M ', ' N ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', ' Y ', ' Z ', ' A ', ' B ', ' C ', ' d ', ' e ' , ' f ', ' g ', ' H ', ' J ', ' K ', ' m ', ' n ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z ');
$string _include_number_list = Array (' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' J ', ' K ', ' M ', ' N ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', ' Y ', ' Z ', ' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' H ', ' J ', ' K ', ' m ', ' n ', ' P ', ' Q ', ' R ', ' s ', ' T ', ' U ', ' V ', ' w ', ' x ', ' y ', ' z ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ');
if ($include _number) {
$arr = $string _include_number_list;
} else {
$arr = $string _list;
}
$rand _max = count ($arr)-1;
$return _string = null;
for ($i = 0; $i < $len; $i + +) {
$rand = Mt_rand (0, $rand _max);
$return _string. = $arr [$rand];
}
return $return _string;
}
3. Write a blog to keep the chaos