类封装验证图如何输出+js
这是用类封装的一个验证图 我的问题是如何在另外一个页面上调用它
php coderandcodelength = 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); }}?>
下面是输出页面
php code