久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      如何在php中生成驗(yàn)證碼圖片

      1.獲取生成驗(yàn)證碼字體:

      在php文件路徑新建一個(gè)fonts文件夾,里面有字體文件。

           //判定字體資源       if(empty($fonts))          $fonts="arial.ttf";        //確認(rèn)字體路徑       $fonts=__DIR__."/fonts/".$fonts;       $fonts=str_replace("/","\",$fonts);

      2.制作畫布,隨機(jī)分配背景色

      $img=imagecreatetruecolor($width,$height);        $bg_color=imagecolordeallocate($img,mt_rand(200,255),mt_rand(200,250)); imagefilter($img,0,0,$bg_color);

      3.增加干擾點(diǎn)、線

      //增加干擾點(diǎn):*       for($i = 0;$i < 50;$i++)       {       //隨機(jī)顏色        $dots_color = imagecolorallocate($img, mt_rand(140,190), mt_rand(140,190), mt_rand(140,190));       //使用*號(hào)作為干擾點(diǎn)        imagestring($img, mt_rand(1,5), mt_rand(0,$width), mt_rand(0,$height), '*', $dots_color);       }      //增加干擾線      for($j = 0;$j < 10;$j++)      {       //隨機(jī)線段顏色       $line_color = imagecolorallocate($img, mt_rand(80,130), mt_rand(80,130), mt_rand(80,130));       //隨機(jī)線段       imageline($img,mt_rand(0,$width),mt_rand(0,$height),mt_rand(0,$width),mt_rand(0,$height),$line_color);      }

      4.將驗(yàn)證碼放入圖片

       $captcha=array(3,4,'a','i');//可以自己使用寫一個(gè)方法生成數(shù)組;  $length=sizeof($captcha);    for($i = 0;$i < $length;$i++){    //給每個(gè)字符分配不同顏色    $c_color = imagecolorallocate($img, mt_rand(0,60), mt_rand(0,60), mt_rand(0,60));        //增加字體空間、大小、角度顯示 imagettftext($img,mt_rand(15,25),mt_rand(-45,45),$width/($length+1)*($i+1),mt_rand(25,$height-25),$c_color,$fonts,$captcha[$i]);   }

      5.保存圖片

      imagejpeg($img,"test.jpg",100);

      推薦:php視頻教程 php教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)