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

PHP custom function: generate new password function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:41:21
Original
996 people have browsed it

  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,...
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template