标签:c color a 文件 2014 string
php 验证码
1、生成图片
imagecreatetruecolor(图片的宽,图片的高):创建一张增彩色的图片
$img = imagecreatetruecolor(80,30);
2、生成颜色(背景)
当第一次调用生成颜色的方法,是生成背景的颜色
imagecolorallocate(图片,红,绿,蓝):
$back =
imagecolorallocate($img,0,0,0):创建为黑色背景
3、第二次生成颜色(字体)
当第二次调用这个方法,是可以生成图片上面的文字或其它样式的颜色
imagecolorallocate(图片,红,绿,蓝):
$color =
imagecolorallocate($img,255,255,255):白色的字体
4、图片上生成文字
imagestring(图片,字体大小,x,y,"生成的字",颜色)
$font =
imagestring($img,5,20,7,"$rand",$color);
5、把php当成图片输出,给文件的申明:
header("content-type:image/jpeg")
6、最终生成
imagejpeg(图片);
imagejpeg($img);
7、图片随机数的生成(数字和字母)
$input = array("a", "b","c", "d","e",
"f","g", "h","i", "j","k", "l","m", "n","o", "p","q", "r","s", "t", "o",
"v","w", "x","y",
"z","1","2","3","4","5","6","7","8","9",);
$rand="";
for($i=1;$i<=4;$i++){
$rand.=$input[rand(0,count($input)-1)];
}
echo $rand;
2014-05-13 总结,布布扣,bubuko.com
2014-05-13 总结
标签:c color a 文件 2014 string
原文地址:http://www.cnblogs.com/zouyajun/p/3726681.html