生成随机验证码

/**
* 生成随机验证码 
* @param string $len 验证码长度
*    @return string
**/
function GetRandStr($len) 
{ 
  $chars = array(

    "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" , "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" , "L" , "M" , "N" , "O" , "P" , "Q" , "R" , "S" , "T" , "U" , "V" ,"W" , "X" , "Y" , "Z"

  ); 
  $charsLen = count($chars) - 1; 
  shuffle($chars); 
  $output = ""; 
  for ($i=0; $i<$len; $i++) 
  { 
    $output .= $chars[mt_rand(0, $charsLen)]; 
  } 
  return $output; 
}
原文地址:https://www.cnblogs.com/yhdsir/p/4648571.html