生成验证码函数
function MakePass($length){
$possible = "0123456789".
"abcdefghijklmnopqrstuvwxyz".
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str = "";
while(strlen($str) < $length){
$str .= substr($possible, (rand() % strlen($possible)), 1);
}
return($str);
}
调用
echo MakePass(5);
//生成5位验证码