欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

验证码类,php验证码类

程序员文章站 2022-05-11 11:29:49
...

验证码类,php验证码类

熟悉相关图像处理函数,简单的验证码类


1
//code class 2 class ValidateCode { 3 private $charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789'; //random effects 4 private $code; //code 5 private $codelen = 4 ; //code length 6 private $width = 130; //width 7 private $heigth = 50; //height 8 private $img; //image handle 9 private $font; //font file 10 private $fontsize = 20; //font size 11 private $fontcolor; //font color 12 13 //the construct initialization 14 public function __construct(){ 15 $this->font = ROOT_PATH.'/font/elephant.ttf'; 16 } 17 18 //create random code from $charset 19 private function createCode(){ 20 $_len = strlen($this->charset); 21 for($i=1;$i$this