Home >php教程 >php手册 >php自定义函数:生成新密码函数

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:39:51979browse

  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
  9. {   
  10.     $password.=$validchars[mt_rand(0,$max_char)];   
  11. }   
  12.     return $password;   
  13. }   
  14. echo "新密码:".genPassword()."
    ";   
  15. echo "新密码:".genPassword(5,10)."
    ";
  16. ?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn