我的驗證碼顯示不出來,是一堆亂碼,但是好像前幾個字符不變,求問怎么回事?
<?php require_once?'string.func.php'; //通過GD庫做驗證碼 function?varifyImage($sess_name="varify",$type=1,$length=4,$pixel=0,$line=0){ ????session_start(); ????$width=80; ????$height=28; ????$image=imagecreatetruecolor($width,?$height);//創建畫布 ????$white=imagecolorallocate($image,?255,?255,?255);//畫布顏色,白色 ????$black=imagecolorallocate($image,?0,?0,?0);//畫筆顏色,黑色 ????imagefilledrectangle($image,1,1,$width-2,$height-2,?$white);//用填充矩陣填充畫布 ????$chars=buildRandomString($type,$length);//string.func.php中產生隨機字符串的函數 ????$_SESSION[$sess_name]=$chars;//用于比對用戶輸入是否正確 ????$fontfile="../fonts/SIMYOU.TTF";//字體 ????for?($i=0;$i?<?$length;?$i++)?{?//每次產生一個驗證碼字符 ????????$size=mt_rand(14,18); ????????$angle=mt_rand(-15,15); ????????$x=5+$i*$size; ????????$y=mt_rand(20,26); ????????$color=imagecolorallocate($image,mt_rand(50,90),?mt_rand(80,200),?mt_rand(90,180)); ????????$text=substr($chars,$i,1);//從產生的驗證碼中按順序取一位 ????????//以上產生隨機的字符大小、角度、橫坐標、縱坐標、顏色 ????????imagettftext($image,?$size,?$angle,?$x,?$y,?$color,?$fontfile,?$text); ????}??? ????if?($pixel)?{???//加干擾點 ????????$color?=?imagecolorallocate?(?$image,?mt_rand?(?0,?255?),?mt_rand?(?0,?255?),?mt_rand?(?0,?255?)?); ????????for($i?=?0;?$i?<?$pixel;?$i?++)?{ ????????????imagesetpixel?(?$image,?mt_rand(?0,?$width-1),?mt_rand(?0,?$height-1),?$black); ????????} ????}??? ????if?($line)?{????//加干擾線? ????????for($i?=?0;$i<$line;?$i?++)?{ ????????????$color?=?imagecolorallocate($image,mt_rand(0,255?),mt_rand(0,255?),mt_rand(0,?255)); ????????????imageline($image,mt_rand(0,?$width-1),?mt_rand?(?0,?$height-1),?mt_rand?(?0,?$width-1),?mt_rand?(?0,?$height-1),?$color?); ????????} ????} ????header("content_type:image/gif");//告訴瀏覽器要顯示什么類型的圖片 ????imagegif($image);//顯示畫布 ????imagedestroy($image);//銷毀畫布 } varifyImage(); ?>
代碼是照著老師打的(? _ ?)
2016-07-27
2016-07-23
應該就是編碼問題,建議你去查看一下配置文件
2016-07-21
編碼問題吧