日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php简易验证码,PHP简易汉字验证码

發(fā)布時間:2023/12/29 php 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php简易验证码,PHP简易汉字验证码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

實現(xiàn)代碼<?php

/**

* PHP實現(xiàn)簡易漢字驗證碼的思路

*/

// 創(chuàng)建畫布

$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, "STFANGSO.TTF", $text[$i]);

}

// 輸出圖像

header("content-type:image/png");

imagepng($image);

// 銷毀圖像

imagedestroy($image);

效果

總結(jié)

以上是生活随笔為你收集整理的php简易验证码,PHP简易汉字验证码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。