最基本的引入图片出错??
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.
<?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.
...全文
相关推荐
webpack配置打包后图片路径出错的解决
本篇文章主要介绍了webpack配置打包后图片路径出错的解决,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
批量检测图片出错(程序).rar
在图像格式.txt中可以加入图片后缀名,一般支持jpg png tif等,只需要最外层文件夹拖入到程序中即可检测,最终会在“读取出错图片.txt”中显示出错的所有图片
Spine_图片显示出错的处理方法
Spine_图片显示出错的处理方法
网站出错页面图片设计
NULL 博文链接:https://yang8787jie-126-com.iteye.com/blog/1739072
安装出错图片
安装出错图片,请大家帮忙解决


基础编程
