当前位置:Gxlcms > PHP教程 > php自定义函数:生成新密码函数_PHP教程

php自定义函数:生成新密码函数_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

  1. //php生成新密码函数
  2. function genPassword($min = 5, $max = 8)
  3. {
  4. $validchars="abcdefghijklmnopqrstuvwxyz123456789";
  5. $max_char=strlen($validchars)-1;
  6. $length=mt_rand($min,$max);
  7. $password = "";
  8. for($i=0;$i<$length;$i )
  9. {
  10. $password.=$validchars[mt_rand(0,$max_char)];
  11. }
  12. return $password;
  13. }
  14. echo "新密码:".genPassword()."
    ";
  15. echo "新密码:".genPassword(5,10)."
    ";
  16. ?>

www.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,...

人气教程排行