书上的案例,写下来保存以后用的到
<?php
header("Content-Type:text/html;charset=utf-8"); //设置页面的编码风格
header("Content-Type:image/jpeg");//告知浏览器输出的是图片
$image=imagecreate(250,100);//设置画布大小
$bgcolor=imagecolorallocate($image,250,180,180);/设置画布背景颜色
$fontcolor=imagecolorallocate($image,30,30,30);//设置字体颜色
$font="STCAIYUN.TTF";//设置字体
for($a=0;$a<4;$a++){
$rand.=dechex(rand(0,15));
}
$string=$rand;
imagefttext($image,50,7,40,80,$fontcolor,$font,$string);//输出验证码
imagejpeg($image);
imagedestroy($image);
?>