randVerify.php /** * 生成随机验证码 * @param integer $codeLenth:随机验证码长度 * @param string $onlyNumber:默认为只获取数字 * @return number */ function randVerify($codeLenth,$onlyNumber=TRUE) { if ($onlyNumber ==
/**
* 生成随机验证码
* @param integer $codeLenth:随机验证码长度
* @param string $onlyNumber:默认为只获取数字
* @return number
*/
function randVerify($codeLenth,$onlyNumber=TRUE)
{
if ($onlyNumber == TRUE){
$code = '';
for($i = 1 ; $i <=$codeLenth ; $i++){
$code .= rand(0,9);
}
return $code;
}
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$string=time();
$len = 11;
for(;$len>=1;$len--)
{
$position=rand()%strlen($chars);
$position2=rand()%strlen($string);
$string=substr_replace($string,substr($chars,$position,1),$position2,0);
}
return substr($string, 0 , $codeLenth);
}
