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

ostratnet8086 2006-09-05 11:55:35
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.
...全文
338 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
caotian2000 2006-09-05
  • 打赏
  • 举报
回复
header 前不能有任何的字符输出!
ostratnet8086 2006-09-05
  • 打赏
  • 举报
回复
我解决拉 
<img src="inc/img.php">
soft_bird 2006-09-05
  • 打赏
  • 举报
回复
查看你的php文件的开头和末尾 是否有空行 空格等空的东西
以及该php文件所包含的文件
ostratnet8086 2006-09-05
  • 打赏
  • 举报
回复
你说的意思是想
session_start
那样吗
可是我怎么保证他在之前不输出呢??

21,889

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧