In the Yii2 framework, if you use the verification code in the form, you will find a strange little problem, that is, the verification code image will not be refreshed when the web page is refreshed.
Most solutions on the Internet are solved by modifying the code in vendor/yiisoft/yii2/captcha/CaptchaAction.php
1. Modify getVerifyCode() Method's parameter default value (Recommended learning: yii framework )
The default value of the parameter $ Regneate is changed from false to true, so , the program will regenerate it every time it gets the verification code.
2. Modify the run() method
In the place pointed by the red arrow, add a parameter true, which can also solve the problem.
The above is the detailed content of How to change the verification code in yii framework. For more information, please follow other related articles on the PHP Chinese website!