imagepng的奇怪问题
代码如下,奇怪的是把imagepng($im)改为imagepng($im,"kk.png")可以得到图片但是直接输出至浏览器就是显示不出来,一直是红叉,这段代码在另一台机器上能正常运行。是我的php配置问题吗?
<?
header("Content-type: image/png");
srand((double)microtime()*1000000);
$login_check_number=strval(rand("11111","99999"));
//$session->setMember("loginCheckNumber", $login_check_number);
$im = imagecreate(50,20) or die ("Cannot Initialize new GD image stream");
$black = ImageColorAllocate($im, 9,142,204);
$foreColor = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
imageline($im, 1, 1, 350, 25, $black);
imagearc($im, 200, 15, 20, 20, 35, 190, $white);
imagestring($im, 5, 7, 3, $login_check_number, $white);
for($i=0 ; $i < 100 ; $i ++) //加入干扰象素
{
imagesetpixel($im, rand()%50 , rand()%50 , $foreColor);
}
imagepng($im);
imagedestroy($im);
?>
[解决办法]