当前位置:Gxlcms > PHP教程 > PHP 一个随机字符串生成代码

PHP 一个随机字符串生成代码

时间:2021-07-01 10:21:17 帮助过:14人阅读

代码如下:

/*************
*@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;
}

这里是摘自脚本之家之前发布的文章。更多的技巧可以参考。
收集的二十一个实用便利的PHP函数代码

人气教程排行