码迷,mamicode.com
首页 > 其他好文 > 详细

生成验证码

时间:2014-05-14 13:29:21      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:c   color   a   string   type   for   


<?php
$arr = array("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","0","1","2","3","4","5","6","7","8","9");
$r = "";
for($i=1;$i<=4;$i++){
$r.= $arr[rand(0,count($arr)-1)];
echo $r;
}

 

//生成图片
$img = imagecreatetruecolor(100,50);
//背景颜色
$background = imagecolorallocate($img,2,6,8);
//字体颜色
$color = imagecolorallocate($img,200,233,255);
//图片上生成文字
imagestring($img,5,30,20,"$r",$color);
//把php当成图片输出,必须给图片一个头声明
ob_clean();
header("content-type:image/gif");
//最终生成图片
imagegif($img);
?>

生成验证码,布布扣,bubuko.com

生成验证码

标签:c   color   a   string   type   for   

原文地址:http://www.cnblogs.com/ZH1132672711/p/3726716.html

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