99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

使用PHP怎么實現一個漢字驗證碼功能-創新互聯

今天就跟大家聊聊有關使用PHP怎么實現一個漢字驗證碼功能,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。

創新互聯建站專注于企業全網整合營銷推廣、網站重做改版、延長網站定制設計、自適應品牌網站建設、H5開發商城網站制作、集團公司官網建設、外貿營銷網站建設、高端網站制作、響應式網頁設計等建站業務,價格優惠性價比高,為延長等各大城市提供網站開發制作服務。

創建背景畫布


$image = imagecreatetruecolor(200, 60);
$background = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $background);

畫干擾點

for ($i=0; $i < 300; $i++) { 
  $pixColor = imagecolorallocate($image, rand(150, 240), rand(150, 240), rand(150, 240));
  $pixX = rand(10, 190);
  $pixY = rand(5, 55);
  imagesetpixel($image, $pixX, $pixY, $pixColor);
}

畫干擾線

//4條水平線
for ($i=0; $i < 5; $i++) { 
  $lineColor = imagecolorallocate($image, rand(50, 150), rand(50, 150), rand(50, 150));
  $lineX1 = 0;
  $lineX2 = 300;
  $lineY1 = ($i + 1) * 12;
  $lineY2 = ($i + 1) * 12;
  imageline($image, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor);
}

//10條垂直線
for ($i=0; $i < 30; $i++) { 
  $lineColor = imagecolorallocate($image, rand(50, 150), rand(50, 150), rand(50, 150));
  $lineX1 = ($i + 1) * 10;
  $lineX2 = ($i + 1) * 10;
  $lineY1 = 0;
  $lineY2 = 60;
  imageline($image, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor);
}

畫漢字

$text = array('梔', '子', '花', '開');
for ($i=0; $i < 4; $i++) {
  $textColor = imagecolorallocate($image, rand(20, 100), rand(20, 100), rand(20, 100));
  $textX = $i * 50 + 10;
  $textY = rand(40, 60);
  imagettftext($image, 30, rand(20, 50), $textX, $textY, $textColor, "/Library/Fonts/華文仿宋.ttf", $text[$i]);
}

這里注意一下,字體文件一定要支持中文的


編碼要使用utf-8,gbk的中文記得要轉嗎【iconv函數可以幫助你】

輸出圖像

header("Content-Type:image/png");
imagepng($image);

銷毀資源

imagedestroy($image);

經過粗略的搞吧搞吧,中文驗證碼也就顯示出來了,當然一般網站使用的時候會有一個漢字庫種子,從里面隨機取出特定個數的漢字顯示,最后就是記錄到session進行驗證了。

看完上述內容,你們對使用PHP怎么實現一個漢字驗證碼功能有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注創新互聯行業資訊頻道,感謝大家的支持。

新聞標題:使用PHP怎么實現一個漢字驗證碼功能-創新互聯
本文路徑:http://www.yijiale78.com/article28/dodejp.html

成都網站建設公司_創新互聯,為您提供面包屑導航網頁設計公司Google網站維護云服務器品牌網站制作

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

手機網站建設