/**
* @name: 生成随机字符串
* length 输出长度
* chars 字符串
* special true为包含特殊字符
* 除去0,l等
* 字符头和尾不会包含特殊字符
*/
function randpassword($length=8,$special=true)
{
if($special){
$chars = '2345#6789.abcdefghijkmn@pqrstuvwxyz#ABCDEFGHIJKLMN.PQRSTUVWXYZ@';
}else{
$chars = '23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ';
}
$lens=strlen($chars) - 1;
$hash = '';
$str_start = randomLison();
$str_end = randomLison();
for ($i = 0; $i <($length - 2); ++$i) {
$hash .= $chars[mt_rand(0, $lens)];
}
return $str_start . $hash . $str_end;
}
/**
* @name: 生成随机字符串-调用
*/
function randomLison()
{
$allstr = 'abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ';
return $allstr[mt_rand(0, 48)];
}
