$c = $record['corrects'];
$i = $record['incorrects'];
if($c == 0 && $i == 0)
{
$image = imagecreatetruecolor(200,80);
$white = imagecolorallocate($image,255,255,255);
$red = imagecolorallocate($image,255,0,0);
imagefilledrectangle($image,0,0,199,79,$white);
$text = 'Quiz cancelled!';
$box = imageftbbox(10,0,'verdana.ttf',$text);
$x = imagesx($image)/2 - abs($box[2] - $box[0])/2 - 5;
$y = imagesy($image)/2 - abs($box[5] - $box[3])/2 - 5;
imagefttext($image,10,0,$x,$y,$red,'verdana.ttf',$text);
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
exit();
}
anjan
问问题
1206 次
3 回答
2
注释掉 imagepng() 和 header() 调用并在浏览器中查看输出以查看是否生成任何错误
于 2008-12-18T16:41:22.397 回答
1
我试过了,它有效。它产生了一条红色文字,上面写着“测验取消!”。
也许您应该检查 $c 和 $i 是否确实都是 0?
我假设你有 < ? php 和 ? > 文件开头和结尾的标签?
编辑:另外,ttf字体文件在正确的位置吗?
如果您可以提供更多信息,它也可能会有所帮助:浏览器是否出现错误?或者只是什么都不显示?
本
于 2008-12-18T16:41:17.293 回答
1
如前所述,这个问题在细节上有点粗略。
GDFONTPATH 环境变量是否设置正确?
<?php
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
于 2008-12-18T16:46:44.897 回答