| $len表示长度,代码如下: <div class="codetitle"><a style="CURSOR: pointer" data="92028" class="copybut" id="copybut92028" onclick="doCopy('code92028')"> 代码如下:<div class="codebody" id="code92028">
 /*
 产生随机字符串
 
 产生一个指定长度的随机字符串,并返回给用户
 
 @access public
 @param int $len 产生字符串的位数
 @return string
 /
 function randstr($len=6) {
 $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ
 abcdefghijklmnopqrstuvwxyz0123456789-@#~';
 // characters to build the password from
 mt_srand((double)microtime()1000000*getmypid());
 // seed the random number generater (must be done)
 $password='';
 while(strlen($password)<$len)
 $password.=substr($chars,(mt_rand()%strlen($chars)),1);
 return $password;
 }
 
 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |