利用此函数生成随机文件名或强度较高的卡密等
<?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
暂无评论内容