| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
13年前发布

PHP随机数生成器 paptcha

     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>     
 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1324534843749.html
PHP 验证码(Captcha)