Home  >  Article  >  PHP Framework  >  Verification code is not displayed in yii2.0

Verification code is not displayed in yii2.0

王林
王林Original
2020-02-18 16:12:412600browse

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!

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