PHP随机数生成器 paptcha

jopen 13年前
     paptcha 是一个用来生成在网页验证码中使用的随机数的PHP函数。    <pre class="brush:php; toolbar: true; auto-links: false;">function paptcha() {   error_reporting ( E_ERROR );     if (is_int(func_get_arg(0)) && abs(func_get_arg(0)) < 10)  $dig = abs(func_get_arg(0));   else  $dig = 1;     if (is_int(func_get_arg(1)) && abs(func_get_arg(1)) < 10 && abs(func_get_arg(1)) > 1)  $chs = abs(func_get_arg(1));   else  $chs = 2;    for($i = 0; $i < $dig; $i++)    $res .= rand(0, 9);    // I put the result to first position of the choice array  $choices[0] = $res;    // File the choice array with options (numbers)  for($k = 1; $k < $chs; $k++)    for($i = 0; $i < $dig; $i++)      $choices[$k] .= rand(0, 9);     // Mix up a little the numbers   shuffle ($choices);   /*  * I put the result to the final position of the choice array.  * Now we know that one of the results of the array is our Captcha Choice  * and we can verify the answer with the last number of the array  */   $choices[$k] = $res;  return($choices); } //end of func</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324534843749" target="_blank">http://www.open-open.com/lib/view/home/1324534843749</a></p>