首页 > 开发 > PHP > 正文

php 随机生成10位字符代码

2024-05-04 22:11:29
字体:
来源:转载
供稿:网友
代码如下:
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>";


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表