php生成验证码
<?php session_start(); header("content-type:image/png");//设置生成图片的格式这里为png $width=40;//宽度 $height=25;//高度 $color="#ffffff";//色彩 $num=rand(1000,9999);//生成随机数4位 $_SESSION['ver']=$num;保存到session以前验证 $img=imagecreate($width,$height);//使用imagecreate创建图片 $bg1=imagecolorallocate($img,rand(0,100),rand(0,250),rand(0,255));//图片色采 $bg2=imagecolorallocate($img,rand(0,205),rand(0,250),rand(0,245)); //imageline($img,40,20,40,40,$color); //imagesetpixel($img,44,44,$color); imagestring($img,7,4,7,$num,$bg2);//增加杂点 imagepng($img);//生成图片 imagedestroy($img);//销毁 ?>
这个是很简单的,所以就不详细的讲说了.
永久链接:http://www.phprm.com/develop/29ce16715d996cbce74a734d2d1feeb4.html
转载随意!带上文章地址吧。