天天看點

php随機産生六位數密碼

//随機産生六位數密碼Begin
function randStr($len=6,$format='ALL') { 
switch($format) { 
case 'ALL':
$chars='[email protected]#~'; break;
case 'CHAR':
$chars='[email protected]#~'; break;
case 'NUMBER':
$chars='0123456789'; break;
default :
$chars='[email protected]#~'; 
break;
 }
mt_srand((double)microtime()*1000000*getmypid()); 
$password="";
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
 } 
//随機産生六位數密碼End
?>      

  

轉載于:https://www.cnblogs.com/c3055/archive/2011/07/29/2121190.html

php