Sometimes we need to randomly generate usernames and passwords in applications, which can greatly improve the security of the application. To generate random usernames and passwords in PHP, you can use the mt_rand function or the rand function. The rand function is in the verification code. There are more applications, and generating long character random codes generally requires the mt_rand function.
Using PHP to generate random numbers can be used in many places, such as designing random passwords for programs, applications for simulating dice games, rock-paper-scissors game applications, etc.
The following are two function methods for generating random numbers in PHP:
Copy code The code is as follows:
//Automatically generate a random username for the user (length 6-13)
Function Create_password ($ pw_length = 4) {
$ randpwd = '';
for ($ i = 0; $ i & lt; $ i ++) {
$ RANDPWD. = CHR (mt_r_R And (and (and ( " Required characters any character;
// The second method is to take any element of the character array $chars
1);
. //Call this function
$userId = 'user'.generate_username(6);
$pwd = create_password(9);
http://www.bkjia.com/PHPjc/326568.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/326568.html
TechArticle
Sometimes we need to use randomly generated usernames and passwords in applications, which can greatly improve the security of the application. To generate a random username and password in PHP you can use mt...