//自动为用户随机生成用户名(长度6-13)
function create_password($pw_length = 4){
$randpwd = '';
for ($i = 0; $i
$randpwd .= chr(mt_rand(33, 126));
}
return $randpwd;
}
function generate_username( $length = 6 ) {
// 密码字符集,可任意添加你需要的字符
$chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_ []{}~`+=,.;:/?|';
$password = '';
for ( $i = 0; $i
{
// 这里提供两种字符获取方式
// 第一种是使用substr 截取$chars中的任意一位字符;
// 第二种是取字符数组$chars 的任意元素
// $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
$password .= $chars[ mt_rand(0, strlen($chars) - 1) ];
}
return $password;
}
// 调用该函数
$userid = 'user'.generate_username(6);
$pwd = create_password(9);
摘自 hurry的专栏
http://www.bkjia.com/phpjc/478526.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/478526.htmltecharticle//自动为用户随机生成用户名(长度6-13) function create_password($pw_length = 4){ $randpwd = ; for ($i = 0; $i $pw_length; $i++){ $randpwd .= chr(mt_rand(33, 126)); } re...