php.ini里面的gd2已经打开了。就是不知道为什么画图显示图片的那些函数都无法显示图片。请问哪里还要设置?求。如何判断gd2库是否打开正常?

解决方案 »

  1.   

    phpinfo();  查看你的gd库是否开启。。另外你打开错误显示功能看有没有错误提示。。
      

  2.   

    在 phpinfo中检查自己的php.ini文件是否是自己打开的那个文件.
      

  3.   

    文件编码也有可能造成图片不能正常显示,比如UTF8、UNICODE编码文件,默认情况下都BOM头,PHP在执行该文件时会把BOM头一起输出,造成图片数据错误。
    解决方法有两种:
    第一种:使用ASCII编码保存文件
    第二种:保存时设置为无BOM头模式(很多编辑器都有这个选项)
      

  4.   

    我的qq是249616294能不能在qq上教我。
      

  5.   

    function _code($_width = 75, $_height=25,$_rnd_code=4,$_flag=false){
    for ($i=0;$i<$_rnd_code;$i++){
    $_nmsg.=dechex(mt_rand(0,15));
    }
    $_SESSION['code']=$_nmsg;
    $_img=imagecreatetruecolor($_width,$_height);
    $_white=imagecolorallocate($_img,255,255,255);
    imagefill($_img,0,0,$_white);
    if ($_flag){
    $_black=imagecolorallocate(S_img,0,0,0);
    imagerectangle($_img,1,1,$_width-1,$_height-1,$_black);
    }
    for($i=0;$i<1;$i++){
    $_rnd_color=imagecolorallocate($_img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
    imageline($_img,mt_rand(0,$_width),mt_rand(0,$_height),mt_rand(0,$_width),mt_rand(0,$_height),$_rnd_color);
    }
    for($i=0;$i<100;$i++){
    $_rnd_color=imagecolorallocate($_img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
    imagestring($_img,1,mt_rand(1,$_width),mt_rand(1,$_height),'*',$_rnd_color);
    }
    for($i=0;$i<strlen($_SESSION['code']);$i++){
    $_rnd_color=imagecolorallocate($_img,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));
    imagestring($_img,5,$i*$_width/$_rnd_code+mt_rand(1,10),mt_rand(1,$_height/2),$_SESSION['code'][$i],$_rnd_color);
    }
    header('Content-Type:image/png');
    imagepng($_img);
    imagedestroy($_img);
    }
    这是函数的原型。
    函数的调用_code();
      

  6.   

    本帖最后由 xuzuning 于 2011-12-20 13:55:28 编辑
      

  7.   

    周围的几台电脑都可以成功执行,所以我把问题锁定在xampp,但是我不知道如何弄服务器本身。
      

  8.   

    今儿装xampp也出现这个问题了。把php.ini中的error_reporting 改为这个E_ALL & ~E_NOTICE,问题解决