. This can also be achieved by changing the parameters of the verification code. The fontSize parameter refers to the font size of the verification code."/> . This can also be achieved by changing the parameters of the verification code. The fontSize parameter refers to the font size of the verification code.">
search
HomePHP FrameworkThinkPHPHow to set the width and height of thinkphp verification code

How to set the width and height of thinkphp verification code

#Think\Verify class can support the generation and verification functions of verification codes.

In order to display this verification code function, first there must be a controller, then there must be a method, and then there must be a displayed page.

Related recommendations: "ThinkPHP Tutorial"

The simplest way to generate a verification code:

(1) We still continue to write in that controller Method

How to set the width and height of thinkphp verification code

This method displays the page of this verification code

public function xianshi()
{
    $this->show();  
}
public function shengcheng()
{
    //造验证码的对象
    $v = new \Think\Verify();
    //生成验证码
    $v->entry();
}

(2) The page that displays the verification code should still be placed in How to set the width and height of thinkphp verification code , name it How to set the width and height of thinkphp verification code

<img  src="/static/imghwm/default1.png"  data-src="__CONTROLLER__/shengcheng"  class="lazy"   / alt="How to set the width and height of thinkphp verification code" >

Run it and see the results:

How to set the width and height of thinkphp verification code

(3) We can also set the size for it, and every time the page is refreshed, The verification code will change.

Just give him an attribute, for example:

<img  src="/static/imghwm/default1.png"  data-src="__CONTROLLER__/shengcheng"  class="lazy"      style="max-width:90%"  style="max-width:90%" / alt="How to set the width and height of thinkphp verification code" >

Both width and height become larger

How to set the width and height of thinkphp verification code

About verification Code parameters

These parameters can be used to transform the verification code.

How to set the width and height of thinkphp verification code

Note: There are two ways to set parameters.

1. Instantiation incoming parameters:

$config = array(   
    &#39;fontSize&#39;    =>    30,    // 验证码字体大小   
    &#39;length&#39;      =>    3,     // 验证码位数   
    &#39;useNoise&#39;    =>    false, // 关闭验证码杂点
);
$Verify = new \Think\Verify($config);
$Verify->entry();

2. Dynamic settings:

$Verify = new \Think\Verify();
$Verify->fontSize = 30;
$Verify->length   = 3;
$Verify->useNoise = false;
$Verify->entry();

The above is the detailed content of How to set the width and height of thinkphp verification code. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool