This paper describes the implementation method of adding verification code in YII2. Share to everyone for your reference, as follows:
First, add a CAPTCHA field to the model:
Public Function rules () {return [' Verifycode ', ' Captcha '],}
Second, you can add the field name of the verification code in the foreground page in the function Attributelabels:
Public Function Atrributelabels () {return [' verifycode ' = ' verification Code ',];}
Then, make the following modifications in the view file:
Use yii\captcha\captcha;<?= $form->field ($model, ' Verifycode ')->widget (Captcha::classname (), [ ' Template ' = ' {image}{input} ',])?>
It is hoped that this article is helpful to the PHP program design based on YII framework.
The above introduces the implementation method of adding verification code in Yii2, including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.