驗證碼php函數
function verifyImg($width=80,$height=30){//定義畫布$img=imagecreatetruecolor($width, $height);//定義顏色$white=imagecolorallocate($img, 255, 255, 255);$black=imagecolorallocate($img, 0, 0, 0);//畫出畫布imagefilledrectangle($img, 1, 1, $width-2, $height-2, $white);//寫字$size=mt_rand(18,22);$angle=mt_rand(-3,3);$x=mt_rand(2,10);$y=mt_rand(20,28);$fontfiles='../font/simhei.ttf';$_SESSION['verify']=$str=randomStr();imagettftext($img, $size, $angle, $x, $y, $black,$fontfiles ,$str);//增加幹擾點for($i=0;$i<100;$i++){ $x=mt_rand(1,$width-1); $y=mt_rand(1,$height-1); $red=mt_rand(1,150); $green=mt_rand(1,150); $blue=mt_rand(1,150); $color=imagecolorallocate($img, $red, $green, $blue); imagesetpixel($img, $x, $y, $color);}//產生圖片header("content-type:image/gif");imagegif($img);imagedestroy($img);
請大神幫小弟看看是哪裡出了問題了!
搞得我毫無頭緒!
之前一直用得好好的,突然間就用不了了!
GD庫是開了的啊!