Home > Article > PHP Framework > Verification code is not displayed in yii2.0
1. First, make sure that the captcha method in your controller is accessible and has the assigned permissions. This is set in the rule.
2. Make sure your PHP GD plug-in has been enabled;
3. If it still does not display, then try the following method:
(Recommended tutorial: yii framework)
Solution:
First find yii\framework\web\widgets\captcha\CCaptchaAction.php;
Then you can try the following Methods to solve:
1. Try to delete spaces in the text;
2. Add error_reporting(0) at the top of the php file;
3. Add it before the header output ob_clean(); That is:
ob_clean();//加上这行
header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header("Content-type: image/png"); imagepng($image); imagedestroy($image);
For more programming-related content, please pay attention to the Programming Introduction column on the php Chinese website!
The above is the detailed content of Verification code is not displayed in yii2.0. For more information, please follow other related articles on the PHP Chinese website!