您的位置:首页 > 编程语言 > PHP开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: