php 随机生成10位字符代码

2018-10-15 16:59

阅读:489

复制代码 代码如下:
function randStr($len)
{
$chars=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz; // characters to build the password from
$string=;
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$string.=substr($chars,$position,1);
}
return $string;
}
echo randStr(10).<br>;



评论


亲,登录后才可以留言!