Php code for generating a random six-digit password-php Tutorial

Source: Internet
Author: User
Php code to generate a random six-digit password

  1. // Generate a six-digit password Begin at random
  2. Function randStr ($ len = 6, $ format = 'all '){
  3. Switch ($ format ){
  4. Case 'all ':
  5. $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 -@#~ '; Break;
  6. Case 'char ':
  7. $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz -@#~ '; Break;
  8. Case 'number ':
  9. $ Chars = '20140901'; break;
  10. Default:
  11. $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 -@#~ ';
  12. Break;
  13. }
  14. Mt_srand (double) microtime () * 1000000 * getmypid ());
  15. $ Password = "";
  16. While (strlen ($ password) <$ len)
  17. $ Password. = substr ($ chars, (mt_rand () % strlen ($ chars), 1 );
  18. Return $ password;
  19. }
  20. // Generate a random six-digit password End
  21. ?>

For articles on generating random passwords or random numbers in php, the script school has provided many articles for you. if you are interested, read the following articles: php random verification code (text) php functions used to generate random user names and passwords. php programs used to generate random user names in batches. two methods used to generate random numbers in php: random code generation using php php generates a random string code php creates a code that can read a random string php randomly outputs a famous saying function to randomly extract some elements from the array php code php generates a random number example is very practical 3 PHP random string function generator a simple php random generation string function PHP generate random string two methods PHP generate random string two examples php generate random string function php random password generation function php: Generate random username and random password php: Generate random password function PHP: Generate random string function php: Generate random password custom function php: Generate random password several method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.