/**
* 获取随机字符串
* @param int $len 字符串长度
* @param string $chars 字符源
* @return string
*/
function getRandomString($len, $chars = null)
{
if (is_null($chars))
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for ($i = 0, $str = '', $lc = strlen($chars) - 1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
}
return $str;
}