Home >Backend Development >PHP Tutorial >PHP random password generator_PHP tutorial
I found a PHP random password generation program from a foreign website. You can first define the base, and then use mt_rand and substr to get the Nth character.
Randomly generated password: m1ztpxw8
代码如下 | 复制代码 |
function genPwd($length=6) { $password = ''; $possible = '23456789bcdfghjkmnpqrstvwxyz'; $i = 0; while ($i < $length) { $password .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $password; } ?> |
Test method
The code is as follows
|
Copy code | ||||
http: //www.bkjia.com/PHPjc/631699.html