Home > Backend Development > PHP Tutorial > Custom function for php to generate random passwords (reprint and share), php customization_PHP tutorial

Custom function for php to generate random passwords (reprint and share), php customization_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:01:11
Original
1130 people have browsed it

php custom function to generate random password (reprint and share), php customization

php custom function to generate random password

Release time: 2015-03-24 Editor: Script School
Custom function to generate random password in php ​

A function that generates a random password. The generated password is a random string of lowercase letters and numbers, and the length can be customized.

Copy codeThe code is as follows: /*
* php automatically generates a new password custom function (with example demonstration)
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; .genPassword()."
";
echo "New password:".genPassword(5,10)."
";
?>
This article is reproduced from Scripting School http://www.jbxue.com
View original text: Custom function for generating random passwords in PHP


http://www.bkjia.com/PHPjc/972512.html

truehttp: //www.bkjia.com/PHPjc/972512.htmlTechArticlephp custom function to generate random passwords (reprint and share), php custom php custom function to generate random passwords Release time: 2015-03-24 Editor: Script School php automatically generates random passwords...
Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template