Home >Backend Development >PHP Tutorial >PHP generate random password function example

PHP generate random password function example

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:51:22917browse
  1. #Generate random password
  2. function MakePass($length)
  3. {
  4. $possible = "0123456789!@#$%^&*()_+".
  5. "abcdefghijklmnopqrstuvwxyz".
  6. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  7. $ str = "";
  8. while(strlen($str) < $length)
  9. {
  10. $str .= substr($possible, (rand() % strlen($possible)), 1);
  11. }
  12. return( $str);
  13. }
Copy code


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