Home > Backend Development > PHP Tutorial > PHP generates random password custom function code (simple and fast)_PHP tutorial

PHP generates random password custom function code (simple and fast)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:30:01
Original
909 people have browsed it

Implement the code, copy and use:

header("Content-type:text/html;charset=utf-8");
function getRandPass($length = 6){
$password = '';
//Add the characters you want to the string below, the default is numbers 0-9 and 26 English letters
$chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
$char_len = strlen($chars);
for($i=0;$i<$length;$i++){
$loop = mt_rand(0, ($char_len-1) );
//Treat this string as an array, randomly pick out a character, and loop into the number of digits you need
$password .= $chars[$loop];
}
return $password;
}
echo getRandPass(12); //Randomly generate a 12-digit password

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/768134.htmlTechArticleImplement the code, copy and use: ?php header("Content-type:text/html;charset=utf- 8"); function getRandPass($length = 6){ $password = ''; //Add the characters you want to the string below...
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