php生成随机数:自定义函数 randstr($length)
2012-12-31 13:46
225 查看
php生成随机数:自定义函数 randstr($length)
function randstr($len=6){
$chars='abcdefghijklmnopqrstuvwxyz0123456789';
#characters to build the password from
mt_srand((double)microtime()*1000000*getmypid());
#seed the random number generater (must be done)
$password='';
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
}
$salt = randstr();//可用于Discuz! X2.5 pre_ucenter_members
function randstr($len=6){
$chars='abcdefghijklmnopqrstuvwxyz0123456789';
#characters to build the password from
mt_srand((double)microtime()*1000000*getmypid());
#seed the random number generater (must be done)
$password='';
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
}
$salt = randstr();//可用于Discuz! X2.5 pre_ucenter_members
相关文章推荐
- php生成随机数 自定义函数 randstr($length)
- PHP生成不重复随机数的方法汇总
- php生成随机数或者字符串的代码
- PHP不重复随机数的生成方法
- 用PHP生成随机数的函数
- PHP CodeBase: 生成N个不重复的随机数
- php简单生成随机数的方法
- php随机数怎么获取?一个简单的函数就能生成
- php生成随机数
- PHP:生成不重复随机数
- php生成不重复随机数、数组的4种方法分享
- PHP生成不重复随机数的方法汇总
- PHP生成随机数的方法实例分析
- php生成随机数的三种方法
- php生成随机数
- PHP生成N个不重复的随机数
- php生成2位小数的随机数,随机数字+字母
- 用PHP生成随机数的函数(代码示例)
- php生成随机数