首页 > 其他 > 详细

生成验证码

时间:2014-05-14 13:28:54      阅读:371      评论:0      收藏:0      [点我收藏+]


<?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

生成验证码

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!