php自定义函数:生成新密码函数_PHP教程
时间:2021-07-01 10:21:17
帮助过:3人阅读
- //php生成新密码函数
- 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()."
"; - echo "新密码:".genPassword(5,10)."
"; - ?>
http://www.bkjia.com/PHPjc/486149.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486149.htmlTechArticle?php //php生成新密码函数 function genPassword($min = 5, $max = 8) { $validchars="abcdefghijklmnopqrstuvwxyz123456789"; $max_char=strlen($validchars)-1; $length=mt_rand($min,...