最基本的引入图片出错??
Login.php
<?PHP session_start();
require("inc/img.php");?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理登陆</title>
<link type="text/css" rel="stylesheet" href="Css/Public.css" />
</head>
...
<?php SetupImg();?>
</html>
img.php
<?php
function SetupImg()
{
// set up image
$height = 20;
$width = 60;
$im = imagecreatetruecolor($width, $height);
$white = ImageColorAllocate ($im, 255, 255, 255);
$blue = ImageColorAllocate ($im, 244, 91, 26);
// draw on image
ImageFill($im, 0, 0, $blue);
//ImageLine($im, 0, 0, $width, $height, $white);
$str=strtoupper(substr(md5(rand(0,100000)),0,5));
$_SESSION['Code']=$str;
ImageString($im, 10, 4, 2, $_SESSION['Code'], $white);
for($i=0;$i<200;$i++)
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
// output image
Header ('Content-type: image/png');
ImagePng ($im);
// clean up
ImageDestroy($im);
}
?>
提示:Cannot modify header information - headers already sent by (output started at G:\Corp Code\Web\����nage\Login.php:14) in G:\Corp Code\Web\����nage\inc\img.php on line 5
我知道是因为 img.php用了Header但是 我不知道 怎么解决,请高手帮忙.我才刚开始学PHP.