<?php
for ($i=0;$i<4;$i++) {
$nmsg .= dechex(mt_rand(0,15));
}
header('Content-Type: image/png');
$im = imagecreatetruecolor(75,25);
$blue = imagecolorallocate($im,0,102,255);
$white = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$blue);
imagestring($im,5,20,5,$nmsg,$white);
imagepng($im);
imagedestroy($im);
?>
在360中全是乱码,火狐直接就是黑乎乎一片,实在看不出有什么问题,求教高手
for ($i=0;$i<4;$i++) {
$nmsg .= dechex(mt_rand(0,15));
}
header('Content-Type: image/png');
$im = imagecreatetruecolor(75,25);
$blue = imagecolorallocate($im,0,102,255);
$white = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$blue);
imagestring($im,5,20,5,$nmsg,$white);
imagepng($im);
imagedestroy($im);
?>
在360中全是乱码,火狐直接就是黑乎乎一片,实在看不出有什么问题,求教高手
for ($i=0;$i<4;$i++) {
$nmsg .= dechex(mt_rand(0,15));
}
header('Content-Type: image/png');
$im = imagecreatetruecolor(75,25);
$blue = imagecolorallocate($im,0,102,255);
$white = imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$blue);
imagestring($im,5,20,5,$nmsg,$white);
imagepng($im);
imagedestroy($im);
?>
保存为wudom的。开头结束一个空格没有。才行
出现这种现象的原因就在于这个函数: header("Content-type:image/jpeg"); 注意:header函数的作用在于告诉浏览器下面的内容要以什么方式输出,比如: header("Content-type:html/text");表示告诉浏览器后面要的内容要以html文本形式输出; header("Content-type:application/stream"); 表示告诉浏览器后面的内容要以字节流的形式输出; header("Content-type:image/jpeg");表示告诉浏览器后面的内容要以图片的形式输出。看看这篇文章就知道了:http://www.phpnewer.com/index.php/Cjwt/detail/id/10