function yzm($type,$length){
$num = '0123456789';
$word = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$result = '';
switch($type){
case 1: //生成数字类型验证码
for ($i=0;$i
$result .= $num[rand(0,strlen($num)-1)];
}
break;
case 2: //生产字母类型验证码
for ($i=0;$i
$result .= $word[rand(0,strlen($word)-1)];
}
break;
case 3: //生产字母+数字类型验证码
for ($i=0;$i
$incl = $num.=$word;
$result .= $incl[rand(0,strlen($incl)-1)];
}
break;
}
return $result;
}
echo yzm(3,4);
?>