Home > php教程 > php手册 > php生成验证码

php生成验证码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:58:44
Original
777 people have browsed it

本站原创转载请注明来处


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);//销毁


?>

这个是很简单的,所以就不详细的讲说了.

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template