tp5验证码配置函数
//显示验证码 public function show_captcha(){ $captcha = new \think\captcha\Captcha(); $captcha->imageW=120; $captcha->imageH = 30; //图片高 $captcha->fontSize =13; //字体大小 $captcha->length = 4; //字符数 $captcha->fontttf = '5.ttf'; //字体 $captcha->expire = 30; //有效期 $captcha->useNoise = false; //不添加杂点 $captcha->bg = [255,255,255];//背景色 $captcha->useCurve = false; //是否画混淆曲线 return $captcha->entry(); }
调用验证码
<img class="code_img" src="/login/show_captcha" onclick="this.src='/login/show_captcha?'+Math.random();" alt="captcha" />