13.2.2 验证码类的编写1

13.2.2 验证码类的编写1

code.php

getcode();
    //将验证码图片输出
    $vcode->outimg();

reg.php


    
username:
password:
code:

vcode.class.php

width = $width;
            $this->height = $height;
            $this->num = $num;
            $this->code = $this->createcode(); //调用自己的方法
        }



        //获取字符的验证码, 用于保存在服务器中
        function getcode() {
            return $this->code;
        }

                

        //输出图像
        function outimg() {
            //创建背景 (颜色, 大小, 边框)
            $this->createback();

            //画字 (大小, 字体颜色)


            //干扰元素(点, 线条)
            

            //输出图像
        }

        //创建背景
        private function createback() {
        
        }

        //画字
        private function outstring() {
        
        }

        //设置干扰元素
        private function setdisturbcolor() {
        
        }

        //输出图像
        private function printimg() {
            
        }

        //生成验证码字符串
        private function createcode() {
            $codes = "3456789abcdefghijkmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY";

            $code = "";

            for($i=0; $i < $this->num; $i++) {
                $code .=$codes{rand(0, strlen($codes)-1)};  
            }

            return $code;
        }

    }

你可能感兴趣的:(13.2.2 验证码类的编写1)