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

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

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

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

相關(guān)文章

最新評(píng)論