画图的程序要单独在一个页面里面,不能和其他的程序混在一起的-------------aaaa.php----------
<?PHP
header("Content-type: image/gif");
$image=imagecreate(200,200);
$maroon=imagecolorallocate($image,100,0,0);
$white=imagecolorallocate($image,255,255,255);
imagefilledrectangle($image,0,0,200,200,$white);
imagerectangle($image,10,10,190,190,$maroon);
imagefilledrectangle($image,50,50,150,150,$maroon);
imagejpeg($image);
imagedestroy($image); ?>--------------index.html----------------------------
下面是图片
<image src=aaaa.php>
上面是图片
<hr>
你运行index.html是不是看到图片了
<?PHP
header("Content-type: image/gif");
$image=imagecreate(200,200);
$maroon=imagecolorallocate($image,100,0,0);
$white=imagecolorallocate($image,255,255,255);
imagefilledrectangle($image,0,0,200,200,$white);
imagerectangle($image,10,10,190,190,$maroon);
imagefilledrectangle($image,50,50,150,150,$maroon);
imagejpeg($image);
imagedestroy($image); ?>--------------index.html----------------------------
下面是图片
<image src=aaaa.php>
上面是图片
<hr>
你运行index.html是不是看到图片了
直接判斷 if ($_SESSION['3_2']=='on')然后畫線﹐當為TRUE就沒問題﹐但當為FALSE時﹐就沒有輸出圖形﹐這是怎么回事啊哪位師兄幫我看看原碼
<?
header("Content-type: image/png");
$im = imagecreate(250,250);
$border = ImageColorAllocate($im, 144,144,144);
$white = ImageColorAllocate($im,255,255,255);
$line = ImageColorAllocate($im,255,153,153);
imagefill($im,1,1,$white);switch($_SESSION['N'])
{
case 3:
if ($_SESSION['3_2']=='on')
{
imageline($im,125,45,56,165,$line);
}
if ($_SESSION['4_2']=='on')
{
imageline($im,125,45,194,165,$line);
}
if ($_SESSION['4_3']=='on')
{
imageline($im,56,165,194,165,$line);
} imagearc($im,125, 45, 25, 25, 0, 360,$border);
imagefilltoborder($im,125,45,$border,$white); imagearc($im, 56, 165, 25, 25, 0, 360,$border);
imagefilltoborder($im,56,165,$border,$white);
imagearc($im,194, 165, 25, 25, 0, 360,$border);
imagefilltoborder($im,194,165,$border,$white); imagestring($im,5,122,38,"1",$line);
imagestring($im,5,52,158,"2",$line);
imagestring($im,5,190,158,"3",$line); Imagepng($im);
break; case 4:
if ($_SESSION['3_2']=='on')
{
imageline($im,45,45,45,205,$line);
}
if ($_SESSION['4_2']=='on')
{
imageline($im,45,45,205,205,$line);
}
if ($_SESSION['5_2']=='on')
{
imageline($im,45,45,205,45,$line);
}
if ($_SESSION['4_3']=='on')
{
imageline($im,45,205,205,205,$line);
}
if ($_SESSION['5_3']=='on')
{
imageline($im,205,45,45,205,$line);
}
if ($_SESSION['5_4']=='on')
{
imageline($im,205,45,205,205,$line);
}
imagearc($im,45, 45, 25, 25, 0, 360,$border);
imagefilltoborder($im,45,45,$border,$white); imagearc($im,205, 205, 25, 25, 0, 360,$border);
imagefilltoborder($im,205,205,$border,$white); imagearc($im,45, 205, 25, 25, 0, 360,$border);
imagefilltoborder($im,45,205,$border,$white); imagearc($im,205, 45, 25, 25, 0, 360,$border);
imagefilltoborder($im,205,45,$border,$white); imagestring($im,5,42,38,"1",$line);
imagestring($im,5,42,198,"2",$line);
imagestring($im,5,202,198,"3",$line);
imagestring($im,5,202,38,"4",$line);
Imagepng($im);
break; case 5:
if ($_SESSION['3_2']=='on')
{
imageline($im,125,25,25,100,$line);
}
if ($_SESSION['4_2']=='on')
{
imageline($im,125,25,65,205,$line);
}
if ($_SESSION['5_2']=='on')
{
imageline($im,125,25,185,205,$line);
}
if ($_SESSION['6_2']=='on')
{
imageline($im,125,25,225,100,$line);
} if ($_SESSION['4_3']=='on')
{
imageline($im,25,100,65,205,$line);
}
if ($_SESSION['5_3']=='on')
{
imageline($im,25,100,185,205,$line);
}
if ($_SESSION['6_3']=='on')
{
imageline($im,225,100,25,100,$line);
} if ($_SESSION['5_4']=='on')
{
imageline($im,65,205,185,205,$line);
}
if ($_SESSION['6_4']=='on')
{
imageline($im,225,100,65,205,$line);
} if ($_SESSION['6_5']=='on')
{
imageline($im,225,100,185,205,$line);
}
imagearc($im,125, 25, 25, 25, 0, 360,$border);
imagefilltoborder($im,125,25,$border,$white); imagearc($im,225, 100, 25, 25, 0, 360,$border);
imagefilltoborder($im,225,100,$border,$white); imagearc($im,25, 100, 25, 25, 0, 360,$border);
imagefilltoborder($im,25,100,$border,$white); imagearc($im,65, 205, 25, 25, 0, 360,$border);
imagefilltoborder($im,65,205,$border,$white); imagearc($im,185, 205, 25, 25, 0, 360,$border);
imagefilltoborder($im,185,205,$border,$white); imagestring($im,5,122,18,"1",$line);
imagestring($im,5,22,92,"2",$line);
imagestring($im,5,222,92,"5",$line);
imagestring($im,5,62,198,"3",$line);
imagestring($im,5,182,198,"4",$line);
Imagepng($im);
break; default:
break;
}
?>