<?php
/*
* php自動生成新密碼自定義函數(帶實例演示)
適用環境: PHP5.2.x /
mysql 5.0.x
代碼做者: xujiajay
聯繫方式: xujiaphp@gmail.com
* */
function genPassword($min = 5, $max = 8)
{
$validchars="abcdefghijklmnopqrstuvwxyz123456789";
$max_char=strlen($validchars)-1;
$length=mt_rand($min,$max);
$password = "";
for($i=0;$i<$length;$i++ )
{
$password.=$validchars[mt_rand(0,$max_char)];
}
return $password;
}
echo "新密碼:".genPassword()."<br>";
echo "新密碼:".genPassword(5,10)."<br>";
?>