浏览html文件将看到一个红色的正方形 //php图片 <?php $img = ImageCreate(200, 200); $clrWhite = ImageColorAllocate($img, 0xff, 0xff, 0xff); $clrRed = ImageColorAllocate($img, 0xff, 0x00, 0x00); $clrBlue = ImageColorAllocate($img, 0x00, 0x00, 0xff); $clrGreen = ImageColorAllocate($img, 0x00, 0xff, 0x00); ImageFilledRectangle($img, 50, 50, 150, 150, $clrRed); ImageRectangle($img, 0, 0, 200 - 1, 200 - 1, $clrBlue); ImageString($img, 5, 50, 160, "A red Squar", $clrGreen); $tpImg = ImageTypes(); if ($tpImg & IMG_PNG) { header('Context-type: image/png'); ImagePNG($img); } else if ($tyImg & IMG_JPG) { header("Content-Type: image/jpeg"); ImageJPEG($img); } else if ($tyImg & IMG_GIF) { header('Content-type: image/gif'); ImageGIF($img); } ?> //html文件 <html> <head> <title> read squr </title> </head> <body> <img src = "squr.php"> </body> </html>