<!DOCTYPE html> <html> <head> <title>test</title> <meta http-equiv="Content-type" content="text/html"> </head> <body> hello <?php $image=imagecreatetruecolor(100,100); $red=imagecolorallocate($image,0xff,0x00,0x00); imagefill($image,0,0,$red); header('Content-type:image/png'); imagepng($image); imagedestroy($image); ?> </body> </html>
問題出在Content-type:image/png
用window的記事本編輯,源代碼文件的編碼utf8會有bom頭、是不是這樣,還需要驗證、