is->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
46 imageline($this->img,mt_rand(0,$this->width),mt_rand(0,$this->height),mt_rand(0,$this->width),mt_rand(0,$this->height),$color);
47 }
48 //雪花
49 for ($i=0;$i<100;$i++) {
50 $color = imagecolorallocate($this->img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
51 imagestring($this->img,mt_rand(1,5),mt_rand(0,$this->width),mt_rand(0,$this->height),'*',$color);
52 }
53 }
54 //输出
55 private function outPut() {
56 header('Content-type:image/png');
57 imagepng($this->img);
58 imagedestroy($this->img);
59 }
60
61 //对外生成
62 public function doimg() {
63 $this->createBg();
64 $this->createCode();
65 $this->createLine();
66 $this->createFont();
67 $this->outPut();
68 }
69
70 //获取验证码
71 public function getCode() {
72 return strtolower($this->code);
73 }
74 }
75 ?>
View Code
今天就写到这里,下一篇加个水印旋转下
|