php 随机生成10位字符

php 随机生成10位字符

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>";

原文地址:https://www.cnblogs.com/fengju/p/6173909.html