同樣的代碼,為何運(yùn)行起來(lái)是個(gè)小方塊
//創(chuàng)建畫布
$width =400;
$height=50;
$images =imagecreatetruecolor($width,$height);
//創(chuàng)建顏色
$white =imagecolorallocate($images,255,255,255);
imagefilledrectangle($images,0,0,$width ,$height,$white);
//創(chuàng)建一個(gè)畫筆顏色
$randColor =imagecolorallocate($images,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/cambriaz.ttf';
$text=mt_rand(1000,9999);
imagettftext($images,$size,$x,$y,$randColor,$fontFile,$text);
//告訴瀏覽器以圖形形式展示
header('content-type:image/png');
//輸入圖像
imagepng($images);
//銷毀 圖形
imagedestroy($images);
2018-09-05
找到問(wèn)題完美呈現(xiàn),imagettftext($images,$size,$x,$y,$randColor,$fontFile,$text); 參數(shù)傳入不正確,正確的應(yīng)該是: