验证码当前页面能显示,其他页面包含验证码页面的时候出现要么 其他内容显示不出来,要么出错,是什么情况?
验证码代码yzm.php
<?php
session_start();
$height = 22;
$width = 50;
$img = ImageCreateTrueColor($width, $height); //创建一个图像
$color = ImageColorAllocate ($img, 255,255,255); //背景色
ImageFill($img, 0, 0, $color); //填充
$times=2;
$yzm=rand(1000,9999);
$_SESSION['yzm']=$yzm;
for($i=0;$i<$times*2;$i++)
{
$color=imagecolorallocate($img,rand(0,156),rand(0,156),rand(0,156));//干扰颜色
imageline($img,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);//设置颜色
$color=imagecolorallocate($img,rand(0,156),rand(0,156),rand(0,156));//设置颜色
imagesetpixel($img,rand(0,$width),rand(0,$height),$color);
}
$white = ImageColorAllocate ($img, 0, 0, 0); //输出字体颜色
ImageString($img, 4, 4, 3,$_SESSION['yzm'], $white); //输出字体
Header("Content-type: image/png");
ImagePng($img);
ImageDestroy($img);
?>
用index.php包含验证码的时候
<?php
require ('yzm.php');
echo "<a href ='index.php'>首页</a>";
?>
这样子下面的首页显示不出来
用index.php包含验证码的时候
<?php
echo "<a href ='index.php'>首页</a>";
require ('yzm.php');
?>
这样子验证码就出错
验证码代码yzm.php
<?php
session_start();
$height = 22;
$width = 50;
$img = ImageCreateTrueColor($width, $height); //创建一个图像
$color = ImageColorAllocate ($img, 255,255,255); //背景色
ImageFill($img, 0, 0, $color); //填充
$times=2;
$yzm=rand(1000,9999);
$_SESSION['yzm']=$yzm;
for($i=0;$i<$times*2;$i++)
{
$color=imagecolorallocate($img,rand(0,156),rand(0,156),rand(0,156));//干扰颜色
imageline($img,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);//设置颜色
$color=imagecolorallocate($img,rand(0,156),rand(0,156),rand(0,156));//设置颜色
imagesetpixel($img,rand(0,$width),rand(0,$height),$color);
}
$white = ImageColorAllocate ($img, 0, 0, 0); //输出字体颜色
ImageString($img, 4, 4, 3,$_SESSION['yzm'], $white); //输出字体
Header("Content-type: image/png");
ImagePng($img);
ImageDestroy($img);
?>
用index.php包含验证码的时候
<?php
require ('yzm.php');
echo "<a href ='index.php'>首页</a>";
?>
这样子下面的首页显示不出来
用index.php包含验证码的时候
<?php
echo "<a href ='index.php'>首页</a>";
require ('yzm.php');
?>
这样子验证码就出错



