验证码类,php验证码类
程序员文章站
2022-05-24 08:33:01
...
验证码类,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