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

验证码在哪加时间的字符串才可以避免读缓存解决方法

程序员文章站 2023-12-24 10:01:51
...
验证码在哪加时间的字符串才可以避免读缓存
这是我用类包装的一个验证图片功能 但是我不知道在哪加时间字符串才可以避免读缓存 还请高手指教下
PHP code

randcodelength = 5;
        $this->imgWidth = 80;
        $this->imgHeight = 20;
        $this->codelength = count($this->code)-1;                //获取数组长度当随机范围

        $this->createrandcode();
        $this->createimg();
        $this->createString();
        $this->drawline($this->line);
        $this->ending();

    }
    function createrandcode(){
        for($i=0;$irandcodelength;$i++){                //初始化验证码
            $this->randcode .= $this->code[rand(0,$this->codelength)];
        }
    }
    function createimg(){                                        //创建图片 前景 背景颜色
        $this->image = imagecreatetruecolor($this->imgWidth,$this->imgHeight);
        $this->background = imagecolorallocate($this->image,0,0,0);
        $this->foreground = imagecolorallocate($this->image,255,255,255);
    }
    function createString(){                                    //创建字符串
        imagestring($this->image,5,rand(5,35),0,$this->randcode,$this->foreground);
    }
    function drawline($some){
        for($i=0;$iimage,rand(1,$this->imgWidth),rand(1,$this->imgHeight),rand(1,$this->imgWidth),rand(1,$this->imgHeight),$this->foreground);
        }
    }
    function ending(){
        ob_clean();                                    //抛弃缓存内容
        header("Content-type: image/jpeg");
        imagejpeg($this->image);
    }
}
?>




------解决方案--------------------
网上搜一大把。


验证码在哪加时间的字符串才可以避免读缓存解决方法
验证码在哪加时间的字符串才可以避免读缓存解决方法

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


上一篇:

下一篇: