. 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.">
Home >PHP Framework >ThinkPHP >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
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 , name it
<img src="__CONTROLLER__/shengcheng" / alt="How to set the width and height of thinkphp verification code" >
Run it and see the results:
(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="__CONTROLLER__/shengcheng" 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
About verification Code parameters
These parameters can be used to transform the verification code.
Note: There are two ways to set parameters.
1. Instantiation incoming parameters:
$config = array( 'fontSize' => 30, // 验证码字体大小 'length' => 3, // 验证码位数 'useNoise' => 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!