Home >Backend Development >PHP Tutorial >PHP custom function: generate new password function_PHP tutorial

PHP custom function: generate new password function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:41:21979browse

  1. //php generates a new password function
  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 "New password:". genPassword()."
    ";  
  15. echo "New password:".genPassword(5,10)."
    ";
http://www.bkjia.com/PHPjc/486149.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486149.htmlTechArticle?php //php generate new password function function genPassword($min = 5, $max = 8) { $ validchars="abcdefghijklmnopqrstuvwxyz123456789"; $max_char=strlen($validchars)-1; $length=mt_rand($min,...
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