php thinkphp generates a random string function generate_password( $length = 8 ) { <br>
// Password character set, you can add any characters you need <br>
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; <br>
$password = ''; <br>
for ( $i = 0; $i < $length; $i++ ) <br>
{ <br>
// There are two ways to obtain characters here <br>
//The first is to use substr to intercept any character in $chars; <br>
//The second is to take any element of the character array $chars <br>
// $password .= substr($chars, mt_rand(0, strlen($chars) – 1), 1); <br>
$password .= $chars[mt_rand(0, strlen($chars) - 1)]; <br>
} <br>
Return $password; <br>
}