百度了 好多东西 都试过了还是不显示   求助

解决方案 »

  1.   

    CImage.class
    <?php
    /*
     * $img=new CImage(72,22,15);
     * $img->printimg('png');
     */
    @session_start();
    class CImage{
    public $width;
    public $heigth;
    public $sessionName='_jms_vcode';
    public $type='png';
    public $charlen=4;
    public $fontSize=15;
    public $ttf;

    private $img;
    private $chars="0123456789";

    function __construct($width=48,$heigth=18,$fontSize=15){
    $this->width=$width;
    $this->heigth=$heigth;
    $this->fontSize=$fontSize;
    $this->img=imagecreate($this->width,$this->heigth);
    $this->ttf=dirname(__FILE__).'/fonts/F2FOCRBczykLTStd-Regular.otf';
    imagefill($this->img,0,0,imagecolorallocate($this->img,230,235,255)); 
    }

    function writeChar($code){
    $charlen=strlen($this->chars);
    $fontLeft=-12;
    for($i=0;$i<strlen($code);$i++){
    $fontSize=mt_rand(-1,1)+$this->fontSize;
    $fontLeft+=$fontSize+mt_rand(0,2);
    $fontTop=$this->heigth-mt_rand(1,5);
    $col=imagecolorallocate($this->img,rand(0,150),rand(0,150),rand(0,150));
    imagettftext($this->img, $fontSize, mt_rand(-20,20), $fontLeft, $fontTop, $col, $this->ttf, $code{$i});
    }
    }

    function writeArc($i){
    while($i--){
    ImageArc($this->img,rand(1,$this->width),rand(10,$this->heigth),rand(20,$this->width),rand(1,$this->heigth),rand(1,360),300, imagecolorallocate($this->img,rand(0,120),rand(0,120),rand(0,120)));
    }
    }

    function writePix($i){
    while($i--){
    imagesetpixel($this->img,rand(0,$this->width),rand(0,$this->heigth),imagecolorallocate($this->img,rand(0,200),rand(0,200),rand(0,200)));
    }
    }

    function printimg($type){
    header("content-type:image/$type");
    $len=strlen($this->chars);
    $code='';
    for($i=0;$i<$this->charlen;$i++) $code.=$this->chars{mt_rand(0,$len-1)};
    $_SESSION[$this->sessionName]=strtolower($code);
    $this->writeChar($code);
    //$this->writeArc(3);
    $this->writePix(20);
    $fun='image'.$type;
    $fun($this->img);
    }

    }
      

  2.   

    user.class.php
    /**
     * 验证码产生器
     */
    public final function vcode($rmt=null){
    $lib_path=$_SERVER['DOCUMENT_ROOT'].'/lib/';
    include_once $lib_path .'classes/CImage.class';
    $width=72;
    $height=24;
    $img=new CImage($width, $height);
    $img->sessionName=$this->vcodeSessionName;
    $img->printimg('png');
    }
      

  3.   

    function.js
    //{{{ 登录相关
    function userBeforLogin(){

    }function userLogin(err, data){
    if(err){
    alert(err);
    $('input[name=vcode]')
    .val('')
    .closest('div')
    .find('.yzmNum img')
    .click();

    }else{
    location='/';
    }
    }//}}}
      

  4.   

    文件编码UTF-8无bom?
      

  5.   

    header()之前是否有输出
      

  6.   

    打开php.ini错误提示
      

  7.   

    确定是否加载图片的GD库,在php的配置文件中。