Php code to generate a random six-digit password
- // Generate a six-digit password Begin at random
- Function randStr ($ len = 6, $ format = 'all '){
- Switch ($ format ){
- Case 'all ':
- $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 -@#~ '; Break;
- Case 'char ':
- $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz -@#~ '; Break;
- Case 'number ':
- $ Chars = '20140901'; break;
- Default:
- $ Chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 -@#~ ';
- Break;
- }
- Mt_srand (double) microtime () * 1000000 * getmypid ());
- $ Password = "";
- While (strlen ($ password) <$ len)
- $ Password. = substr ($ chars, (mt_rand () % strlen ($ chars), 1 );
- Return $ password;
- }
- // Generate a random six-digit password End
- ?>
-
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 |