注册 登录
编程论坛 PHP技术论坛

这段GD库创建图像日历的代码哪里有错误?

theend12 发布于 2010-10-05 20:09, 793 次点击
<?php
$y=date(Y);
$m=date(n);
$w=date(w);
$d=date(j);
$ws[0]="Sun";
$ws[1]="Mon";
$ws[2]="Tue";
$ws[3]="Wed";
$ws[4]="Thu";
$ws[5]="Fri";
$ws[6]="Sat";
$image = imagecreate(80,100);
if ($w==0 || $w==6){
$colorW= imagecolorallocate($image,225,0,0);
}else{
$colorW= imagecolorallocate($image,0,0,255);
}
$colorbk = imagecolorallocate($image,0,0,120);
$colorGreen = imagecolorallocate($image,0,225,0);
$colorB = imagecolorallocate($image,255,255,255);
$colorBlack= imagecolorallocate($image,0,0,0);
imagefill($image,0,0,$colorbk);
imagefilledrectangle($image,10,10,70,90,$colorB);
imagestring($image,5,23,15,$y,$colorBlack);
imagestring($image,5,36,35,$m,$colorGreen);   //这里是26行
imagestring($image,5,32,55,$d,$colorW);
imagestring($image,4,30,75,$ws[$w],$colorW);
header("Content-type: image/gif");
imagegif($image);
?>

Parse error:  syntax error, unexpected T_STRING in D:\wamp\www\exp\Calendar\3.php on line 26
1 回复
#2
gupiao1752010-10-21 18:09
<?php
header("Content-type:image/gif");
date_default_timezone_set('PRC');
$y=date("Y");
$m=date("M");
$w=date("w");
$d=date("D");
$ws[0]="Sun";
$ws[1]="Mon";
$ws[2]="Tue";
$ws[3]="Wed";
$ws[4]="Thu";
$ws[5]="Fri";
$ws[6]="Sat";
$image = imagecreate(80,100);
if ($w==0||$w==6){
$colorW= imagecolorallocate($image,225,0,0);
}else{
$colorW= imagecolorallocate($image,0,0,255);
}
$colorbk = imagecolorallocate($image,0,0,120);
$colorGreen = imagecolorallocate($image,0,225,0);
$colorB = imagecolorallocate($image,255,255,255);
$colorBlack= imagecolorallocate($image,0,0,0);
imagefill($image,0,0,$colorbk);
imagefilledrectangle($image,10,10,70,90,$colorB);
imagestring($image,5,23,15,$y,$colorBlack);
imagestring($image,5,36,35,$m,$colorGreen);   //这里是26行
imagestring($image,5,32,55,$d,$colorW);
imagestring($image,4,30,75,$ws[$w],$colorW);
imagegif($image);
?>
我这里测试了可以啊。
1