时间:2021-07-01 10:21:17 帮助过:43人阅读
- <br><span><u></u></span> 代码如下:<br>/** <br>* 产生随机字符串 <br>* <br>* 产生一个指定长度的随机字符串,并返回给用户 <br>* <br>* @access public <br>* @param int $len 产生字符串的位数 <br>* @return string <br>*/ <br>function randstr($len=6) { <br>$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ <br>abcdefghijklmnopqrstuvwxyz0123456789-@#~'; <br>// characters to build the password from <br>mt_srand((double)microtime()*1000000*getmypid()); <br>// seed the random number generater (must be done) <br>$password=''; <br>while(strlen($password)<$len) <br>$password.=substr($chars,(mt_rand()%strlen($chars)),1); <br>return $password; <br>}<br>