function getRandomString($len, $chars=null)
{
if (is_null($chars)) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
}
mt_srand(10000000*(double)microtime());
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
}
return $str;
}
//可自定义位数
$code=$this->getRandomString(6);
return $code;