imagettftext ( ) 错误 找不到
<?php
require_once 'string.func.php';//只包含一次(把string.func.php内容包含进来)
//通过GD库做验证码
//创建画布
$width = 80;
$height = 28;
$image = imagecreatetruecolor ( $width, $height );
$white = imagecolorallocate ( $image, 255, 255, 255 );//白色用来填充画布
$black = imagecolorallocate ( $image, 0, 0, 0 );//画笔颜色
//用矩形填充画布
imagefilledrectangle ( $image, 1, 1, $width - 2, $height - 2, $white );//用白色填充
$type=1;
$length=4;
$chars = buildRandomString ( $type, $length );//调用(选择类型长度)
$sess_name = "verify";
$_SESSION [$sess_name] = $chars;
$fontfiles = array ("SIMYOU.TTY" );
for($i = 0; $i < $length; $i ++) {
$size = mt_rand ( 14, 18 );//字体大小
$angle = mt_rand ( - 15, 15 );//倾斜角度
$x = 5 + $i * $size;// 横坐标(宽)
$y = mt_rand ( 20, 26 );//纵坐标(高)
$fontfile = "../fonts/". $fontfiles [mt_rand ( 0, count ( $fontfiles ) - 1 )];
//字体文件随机选出一个【0】到【数组长度减一】
$color = imagecolorallocate ( $image, mt_rand ( 50, 90 ),
mt_rand ( 80, 200 ), mt_rand ( 90, 180 ) );//随机颜色
$text = substr ( $chars, $i, 1 );//从i开始取(第一次是零第二次是一),每次取一位
imagettftext ($image, $size, $angle, $x, $y, $color, $fontfile, $text );
}
header ( "content-type:image/gif" );//告诉浏览器要显示的资源
imagegif ( $image );//显示画布
imagedestroy ( $image );//销毁画布资源