首页 » PHP » 函数库 » 阅读文章

用PHP生成一个随机字符串

2012-01-30 11:49 5134 0 发表评论
标签:

PHP创建一个随机字符串,作为用户的随机密码等。

/*************
*@l – length of random string
*/
function generate_rand($l){
$c= “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789”;
srand((double)microtime()*1000000);
for($i=0; $i<$l; $i++) {
$rand.= $c[rand()%strlen($c)];
}
return $rand;
}

本文地址:http://www.jwzzsw.com/archives/1006.html

文章作者:思悟
版权所有 © 转载时请以链接形式注明作者和原始出处!

评论 共0条 (RSS 2.0) 发表评论

  1. 暂无评论,快抢沙发吧。

发表评论

联系我 Contact Me

回到页首