当前位置:Gxlcms > PHP教程 > php随机生成10位字符代码_PHP教程

php随机生成10位字符代码_PHP教程

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

代码如下:
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)."
";


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320028.htmlTechArticle 代码如下:

function randStr($len) { $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; // characters to build the password from $string=''; fo...

人气教程排行