利用php生成验证码
发布:smiling 来源: PHP粉丝网 添加日期:2018-08-02 17:00:19 浏览: 评论:
- <?php
-
-
-
-
-
-
-
-
-
-
- $width= 100;
- $height= 30;
- $vcodelen= 4;
- $pointnum= 200;
- $linenum= 3;
-
- $image= imagecreatetruecolor($width,$height);
-
- $bgcolor= imagecolorallocate($image, 255, 255, 255);
-
- imagefill($image, 0, 0,$bgcolor);
-
- for($i=0;$i<$vcodelen;$i++) {
-
- $fontsize= 5;
-
- $fontcolor= imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
- $data='abcdefghijklmnopqrstuvwxyz0123456789'
-
- $fontcontent=<a href="/tags.php/substr/" target="_blank">substr</a>($data, rand(0,strlen($data)),1);
-
- $x= ($i*$width/4)+rand(5,15);
- $y= rand(5,10);
-
-
- imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
-
- }
-
- for($i=0;$i<$pointnum;$i++) {
- $pointcolor= imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
-
- imagesetpixel($image, rand(0,$width), rand(0,$height),$pointcolor);
- }
-
- for($i=0;$i<$linenum;$i++) {
- $linecolor= imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));
-
- imageline($image, rand(0,$width), rand(0,$height), rand(0,$width), rand(0,$height),$linecolor);
- }
-
- header('content-type: image/png');
-
- imagepng($image);
-
- imagedestroy($image);
- ?>
Tags:
分享到: