欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php生成隨機數(shù)或者字符串的代碼

 更新時間:2008年09月05日 11:57:02   作者:  
一個最簡單的利用php生成隨機數(shù)或者隨機字符串的函數(shù).$chars變量中的字符自己修改就能達到數(shù)字或者字符串的目的
$len表示長度,代碼如下:
復制代碼 代碼如下:

/**
* 產生隨機字符串
*
* 產生一個指定長度的隨機字符串,并返回給用戶
*
* @access public
* @param int $len 產生字符串的位數(shù)
* @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;
}

相關文章

最新評論