圖像在ie瀏覽器顯示正常,在其他瀏覽器顯示亂碼
<?php
/**
* Created by PhpStorm.
* User: OU
* Date: 2017/8/25
* Time: 10:49
*/
header('content-type:text/html;charset=utf-8');
//1.創(chuàng)建畫布
//imagecreatetruecolor($w-8idth,$height);創(chuàng)建畫布,返回資源,返回圖像標識符
$width=500;
$height=300;
$image=imagecreatetruecolor($width,$height);
//2.創(chuàng)建顏色
//imagecolorallocate();創(chuàng)建顏色
$red=imagecolorallocate($image,255,0,0);
$blue=imagecolorallocate($image,0,0,255);
$white=imagecolorallocate($image,255,255,255);
//3.開始繪畫
//橫著寫一個字符
//imagechar(畫布,字體大小,x坐標,y坐標,顏色);水平的繪制一個字符
imagechar($image,5,50,100,'K',$red);
//imagecharup(畫布,字體大小,x坐標,y坐標,顏色);垂直繪制一個字符
imagecharup($image,5,100,200,'i',$blue);
//水平繪制字符串
imagestring($image,5,200,150,'imooc',$white);
//4.告訴瀏覽器以圖片的形式來顯示
ob_clean();
header('context-type:image/jpeg;charset=utf-8');//image/gif image/png
//5.imagejpeg($image);輸出圖像
imagejpeg($image);//image
//6.銷毀資源
imagedestroy($image);
2017-08-28
? header('context-type:image/jpeg;charset=utf-8') ? ?這一句話里的 context ? 改成 content 試試