/**
* @method 生成由大小字母+数字随机字符串
* @param $length
* @return null|string
*/
function getRandomChar($length)
{
$str = null;
$strPol = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($strPol) - 1;
for ($i = 0; $i < $length; $i++) {
$str .= $strPol[rand(0, $max)];
}
return $str;
}
/**
* @method 生成随机数字
* @param $length
* @return string
*/
function getRandomNumber($length)
{
return substr(str_shuffle(time()), 0, $length);
}
Last modification:June 3rd, 2019 at 11:15 am
© The copyright belongs to the author