<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>6-2</title>
</head>
<body>
<?php
header("Content-type:image/png");
$im = @imagecreate(200,100)or die("11");
@imagecolorallocate($im,240,150,225);
$t_color1 = imagecolorallocate($im,0,0,0);
$t_color2 = imagecolorallocate($im,100,100,100);
imagestring($im,5,8,10,"I like PHP!",$t_color1);
imagestringup($im,5,8,90,"Hello!",$t_color2);
imageellipse($im,65,65,55,55,$t_color1);
imagefilledrectangle($im,110,95,160,30,$t_color2);
imagepng($im);
imagedestroy($im);
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>6-1</title>
</head>
<body>
<img src="6-2.php"> 
</body>
</html>
说明:png图片显示不出来,是一个红叉,GD信息如下:
gd
GD Support  enabled  
GD Version  bundled (2.0.34 compatible)  
FreeType Support  enabled  
FreeType Linkage  with freetype  
FreeType Version  2.1.9  
T1Lib Support  enabled  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  
XBM Support  enabled  
求高人指点,本人初学者,谢谢

解决方案 »

  1.   

    <?php
    header("Content-type:image/png");
    $im = @imagecreate(200,100)or die("11");
    @imagecolorallocate($im,240,150,225);
    $t_color1 = imagecolorallocate($im,0,0,0);
    $t_color2 = imagecolorallocate($im,100,100,100);
    imagestring($im,5,8,10,"I like PHP!",$t_color1);
    imagestringup($im,5,8,90,"Hello!",$t_color2);
    imageellipse($im,65,65,55,55,$t_color1);
    imagefilledrectangle($im,110,95,160,30,$t_color2);
    imagepng($im);
    imagedestroy($im);
    ?>把 html 部分去了,试试
      

  2.   

    忘了说了,去掉html后一样显示红叉苦恼中
      

  3.   

    不是你的代码错了,是你应用php的路径错了
    以/作为web的顶目录,试试,比如/web/php/test.php
      

  4.   

    6-2.php
    <?php
    header("Content-type:image/png");
    $im = @imagecreate(200,100)or die("11");
    @imagecolorallocate($im,240,150,225);
    $t_color1 = imagecolorallocate($im,0,0,0);
    $t_color2 = imagecolorallocate($im,100,100,100);
    imagestring($im,5,8,10,"I like PHP!",$t_color1);
    imagestringup($im,5,8,90,"Hello!",$t_color2);
    imageellipse($im,65,65,55,55,$t_color1);
    imagefilledrectangle($im,110,95,160,30,$t_color2);
    imagepng($im);
    imagedestroy($im);
    ?>