码迷,mamicode.com
首页 > Web开发 > 详细

php验证码

时间:2016-11-23 07:59:25      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:span   计算   参数   tab   php   str   class   rand   out   


$chars_array = array(                    $arr=array_merge(range(0,9),range(‘a‘,‘z‘),range(‘A‘,‘Z‘)); #原数组
"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", "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",
);
//count计算
$charsLen = count($chars_array) - 1; // 计算出上面数组的长度

$outputstr = "";

// 第二个参数 代表生成四个随机数
for ($i=0; $i<4; $i++)
{
$outputstr .= $chars_array[mt_rand(0, $charsLen)];
}


echo $outputstr;

php验证码

标签:span   计算   参数   tab   php   str   class   rand   out   

原文地址:http://www.cnblogs.com/TMDD/p/6092183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!