前提
開啟dg2庫
去掉前面的;
注釋,有的可能會帶.dll后綴影響不大
extension=gd2
代碼
<?php
$file = imagecreate(100,50); //先生成圖片資源$color =imagecolorallocate($file,255,255,255); //白色$c = imagecolorallocate($file,0,100,255);imagefill($file,0,0,$c); //兩個數字是顏色填充從哪里開始,0,0代表左上角imagechar($file,10,20,20,'pk',$color); //s生成文字 第一個數字控制文字大小1-5超過五默認為5
imagechar($file,10,40,20,'h',$color); //第2,3個數字是控制文字在圖片中的位置,‘p’是輸入到圖片上的字符
imagechar($file,10,60,20,'p',$color); //imggechar只能輸入一個字符,輸入多個字符,默認為第一個header('Content-Type:image/png'); //輸出圖片格式 //沒有這句輸出的是字符imagepng($file);?>