最基本的引入图片出错??

ostratnet8086 ostratnet8086 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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.
...全文
评论 4
收藏 已收藏
分享
返回顶部
ostratnet8086
基础编程 21,889 成员 140,329 内容