Home  >  Article  >  PHP Framework  >  What should I do if the yii verification code does not come out?

What should I do if the yii verification code does not come out?

藏色散人
藏色散人Original
2020-01-27 16:55:292218browse

What should I do if the yii verification code does not come out?

#yii What should I do if the verification code does not come out? Regarding the problem that the verification code function of yii2 does not display

1, the verification code does not display:

First ensure that the captcha method in your controller is accessible and has the assigned permissions Yes, this is set in the rule.

Second, make sure your PHP GD plug-in has been enabled.

Third, if it still doesn’t display, then try this method, someone else told me.

Solution:

First find yii\framework\web\widgets\captcha\CCaptchaAction.php, you can try the following methods to solve it:

1 Try to delete the spaces in the text

2 Add error_reporting(0);

3 at the top of the php file. Add ob_clean(); before the header output; 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);

Recommended related article tutorials: yii tutorial

The above is the detailed content of What should I do if the yii verification code does not come out?. 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