急,驗證碼顯示不出來?求解答
<?php?
//創建畫布
$width=400;
$height=50;
$image=imagecreatetruecolor($width,$height);
//創建顏色
$white=imagecolorallocate($image,255,255,255);
//繪制矩形并且填充
imagefilledrectangle($image,0,0,$width,$height,$white);
//創建一個畫筆顏色
$randColor=imagecolorallocate($image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
//開始繪畫
$size=mt_rand(20,28);//字體大小取隨機數
$angle=mt_rand(-15,15);//傾斜角度取隨機數
$x=50;//出現在畫布位置的橫坐標
$y=30;//出現在畫布位置的縱坐標
$fontFile='fonts/SIMYOU.TTF';//字體文件存放路徑(window--->運行----->輸入fonts搜索字體)
$text=mt_rand(1000,9999);//顯示內容,取四位數隨機數
imagettftext($image,$size,$angle,$x,$y,$randColor,$fontFile,$text);
//告訴瀏覽器以圖像形式輸出
header('content-type:image/png');
//輸出圖像
imagepng($iamge);
//銷毀畫布
imagedestroy($image);
?>?
2018-05-25
imagepng($iamge);? 這里寫錯了 應該是image
2018-05-14
你創建的文件應該有 bom頭,去掉就可以了,使用Notepad++或者其他的編碼工具