yii的項目開發過程中,經常使用到驗證碼,yii框架提供了ccaptchaaction類,來提供驗證碼圖片功能,經常會碰到驗證碼圖片不顯示的問題。
主要有兩個問題導致:
1、bom問題(把文件涉及到bom的php代碼去掉bom即可)。
2、 輸出圖像之前,沒有加ob_clean()清空輸出緩沖區。
//加此代碼塊解決 if(function_exists('ob_clean')){ @ob_clean(); } imagecolordeallocate($image,$foreColor); 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);
相關文章教程推薦:yii教程
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END