1,驗證碼不顯示:
首先保證你的controler 里面的captcha方法是可訪問的,被分配的權限的,這個在rule里面設置。
第二,保證你的PHP GD插件已經被啟用,
第三如果這樣還是不顯示,那么試試看這個方法吧,別人告訴我的。
解決方法:先找到yii\framework\web\widgets\captcha\CCaptchaAction.php,可以嘗試通過以下幾種方法來解決 :
1 盡量刪除文中的空格
2 在php文件頂部加入error_reporting(0);
3 在header輸出前加入ob_clean(); 也就是:
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);
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);