header("Content-type:  image/png");
        $login_check_number  =  random(5);        
        $h_img  =  imagecreate(40,17);
        $c_black  =  imagecolorallocate($h_img,0,0,0);
        $c_white  =  imagecolorallocate($h_img,255,255,255);
        imagestring($h_img,5,2,1,$login_check_number,$c_black);
        imagepng ($h_img);
        imagedestroy($h_img);    function random($length) {
$hash = "";
$chars = "CEFGHIJKLMNOPQRSTUVWXYZ0123456789cefghijklmnopqrstuvwxyz";
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++)
{
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}

解决方案 »

  1.   

    Array ( [GD Version] => bundled (2.0.34 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => 1 [GIF Read Support] => 1 [GIF Create Support] => 1 [JPG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => [XBM Support] => 1 [JIS-mapped Japanese Font Support] => )这是print_r(gd_info()); 
    的结果。啥意思?好像都是支持的
      

  2.   

    在我这里没问题的,不过这几行代码我还是稍微改了改。不然字体和背景都是黑的,看不见字了$h_img  =  imagecreate(50,17);
    $c_black  =  imagecolorallocate($h_img,0,0,0);
    $c_white  =  imagecolorallocate($h_img,255,255,255);
    imagestring($h_img,5,2,1,$login_check_number,$c_white);
      

  3.   

    会不会是你的浏览器显示不了png文件?症状就是所有的png文件都是叉。
      

  4.   

    不是这个问题,我的浏览器能显示png的,
      

  5.   

    执行phpinfo()后显示的GD部分是什么样子的。
     
      

  6.   

    执行phpinfo()后显示的GD部分都是支持的
      

  7.   

    执行phpinfo()后显示的GD部分
    能不能截个图发上来看看。。
      

  8.   


    我遇到过,可能是浏览器引起的,写成下面的代码试试header("Content-type:  image/x-png"); 
      

  9.   

    sbwsmy出来挖坟?这个代码是正常的.