我已经百度了,常用的解决方法都无效。1,GD库我已经打开了。2,关于BOM的那些问题,应该排除了,因为我用Dreamwearve保存文件时是按了取消BOM保存的。3.文件路径是正确的。  究竟是 什么问题,求大神教!  
<?php
ob_clean();  
session_start();
//生成验证码图片
header("Content-type:image/png");
//全数字
$str="1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f";//要显示的字符,自己可以增加或删除
$list=explode(",",$str);
$r=count($list)-1;
$laststr="";
for($i=0;$i<4;$i++){
$randnum=mt_rand(0,$r);
$laststr .= $list[$randnum];//取出字符,组合成要显示的字符串
}
$_SESSION['code']=$laststr; //将字符串放入SESSION中$img=imagecreate(28,28);//生成图片
$black=imagecolorallocate($img,0,0,0); // 设置颜色
$white=imagecolorallocate($img,255,255,255);
$gray=imagecolorallocate($img,200,200,200);
$red=imagecolorallocate($img,255,0,0);
imagefill($img,0,0,white);//给图片填充颜色//将验证法放入图片
imagestring($im,4,10,8,$laststr,$black);//将验证码放到图片上
for($i=0;$i<50;$i++){//加入干扰元素
imagesetpixel($img,rand()p,rand()0,$black);//加入点状干扰素
imagesetpixel($img,rand()p,rand()0,$red);
imagesetpixel($img,rand()p,rand()0,$gray);
//imagearc($im,rand()p,rand()p,20,20,75,170,$black);//加入弧线干扰素
//imagearc($im,rand()p,rand()p,rand()p,rand()p,$red);//加入弧线干扰素
}

imagepng($img);
imagedestroy($img);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body><div id="center" align="center">


<p align="center"><strong><font size="+4">用户登录</font></strong></p>
        <form action="/sy20/logindo.php" method="post">
用户名:<input type="text" name="username" size='21' value=""/>
        <br />
密&nbsp;码:  <input type="password" name="password"  size="20"/>
        <br />
       验证码: <input type="text" name="code" size="10"/>
        <img alt="看不清楚,换一张" id="code" src="/sy20/create_code1.php" style="cursor: pointer; vertical-align:middle;" onclick="create_code()"/>
        <button type="button" onClick="create_code()">更换</button>
        </br>
        <p align="center"><input type="checkbox" name="save" value="1"/> 是否保存用户名&nbsp;&nbsp;&nbsp; &nbsp;<a href="##">忘记密码?</a></p>
<br />
        
<input type="submit" value="登录"  name="login"  data-ajax='false'/> 
         <input type="submit" value="注册"  name="zhuce"/>
</form>
    
</div>
<script>
function create_code(){
document.getElementById('code').src='create_code1.php?'+Math.random()*10000;
}
</script>
</body>
</html>