Generate a random password function. The generated password is a random string of lowercase letters and numbers. The length can be customized. Copy the Code as follows :? Php ** php automatically generate new password user-defined functions (with instance demo) applicable environment: PHP5.2.xmysql5.0. x code Author: xujiajay contact: xujiaphp@gmail.com ** fu
Generate a random password function. The generated password is a random string of lowercase letters and numbers. The length can be customized. The Code is as follows :? Php/** php automatically generate new password custom function (with instance demo) applicable environment: PHP5.2.x/mysql5.0.x code Author: xujiajay contact: xujiaphp@gmail.com **/fu
Generate a random password function. The generated password is a random string of lowercase letters and numbers. The length can be customized.
The Code is as follows:
/*
* Php automatically generates a new password User-Defined Function (with instance demo)
Applicable environment: PHP5.2.x/mysql 5.0.x
Code Author: xujiajay
Contact: xujiaphp@gmail.com
**/
Function genPassword ($ min = 5, $ max = 8)
{
$ Validchars = "abcdefghijklmnopqrstuvwxyz123456789 ";
$ Max_char = strlen ($ validchars)-1;
$ Length = mt_rand ($ min, $ max );
$ Password = "";
For ($ I = 0; $ I <$ length; $ I ++)
{
$ Password. = $ validchars [mt_rand (0, $ max_char)];
}
Return $ password;
}
Echo "New Password:". genPassword ()."
";
Echo "New Password:". genPassword (5, 10 )."
";
?>
View Original article: php user-defined function for generating random passwords