/**
* 生成随机码(默认六位)
* 一般放在common中
* @param unknown $length 生成的随机码的长度
* @return string 返回随机码
*/
function GetRand( $length = 6 ) {
// 密码字符集,可任意添加你需要的字符
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$password = '';
for ( $i = 0; $i < $length; $i++ ) {
// 使用 substr 截取$chars中的任意一位字符;
$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $password;
} 如果帮助到你,请赏杯奶茶喝~
- 本文链接: https://www.shx1024.top//index/article/details/article_id/90.shtml
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。