PHP生成随机字符

利用此函数生成随机文件名或强度较高的卡密等

<?php
function randStr($len = 6)
{
    $chars = 'ABDEFGHJKLMNPQRSTVWXYabdefghijkmnpqrstvwxy23456789#%*';
    mt_srand((float) microtime() * 1000000 * getmypid());
    $password = '';
    while (strlen($password) < $len)
        $password .= substr($chars, (mt_rand() % strlen($chars)), 1);
    return $password;
}
echo randStr();
?>

修改版本,随机生成一个12位数的密码

THE END
喜欢就支持一下吧
点赞11 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容