国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

p-hp生成圖片驗證碼

2019-11-02 14:21:15
字體:
來源:轉載
供稿:網友

   驗證碼在WEB應用中非常重要,通常用來防止用戶惡意提交表單,如惡意注冊和登錄、論壇惡意灌水等。本文將通過實例講解使用PHP生成常見的驗證碼

  先給看下 大致的效果

  那么接下來的就直接貼代碼吧

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 <?php $image = imagecreatetruecolor(100, 30); //創建畫布 $imagecolor = imagecolorallocate($image, 255, 255, 255); //背景色 imagefill($image, 0, 0, $imagecolor); //填充背景色 for($i=0;$i<4;$i++ ){ //循環4位數 $fontsize = 6; $fontcolor = imagecolorallocate($image, rand(0, 200), rand(0, 200), rand(0, 200)); $fontcontent = rand(0, 9); $x = $i*100/4 + rand(5, 15); $y = rand(5, 10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); } for($i=0;$i<200;$i++ ){ //循環 添加干擾點 $pointcolor = imagecolorallocate($image, rand(50, 200), rand(50, 200), rand(50, 200)); $x = rand(1, 99); $y = rand(1, 29); imagesetpixel($image, $x, $y, $pointcolor); } for($i=0;$i<3;$i++){ //循環 添加干擾線 $linecolor = imagecolorallocate($image, rand(100, 250), rand(100, 250), rand(100, 250)); $x1 = rand(1, 25); $x2 = rand(50, 75); $y1 = rand(1, 15); $y2 = rand(15, 25); imageline($image, $x1, $y1, $x2, $y2, $linecolor); } header("content-type:image/png"); imagepng($image); imagedestroy($image); ?>

  再給大家分享一個可以生成中文驗證碼

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 <?php //1.qi啟用gd庫GD庫提供了一系列用來處理圖片的API,使用GD庫可以處理圖片,或者生成圖片。 // 在網站上GD庫通常用來生成縮略圖或者用來對圖片加水印或者對網站數據生成報表。 session_start();   // 把GBK編碼的字符串轉換成UTF-8字符串,第一個參數之所以寫GBK,是因為本php文件在主機中存儲的編碼是GBK編碼 // UTF-8編碼
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江安县| 师宗县| 太保市| 尉犁县| 长乐市| 米泉市| 石柱| 南开区| 东兴市| 丽水市| 册亨县| 泗洪县| 兰溪市| 老河口市| 延长县| 隆子县| 分宜县| 子长县| 余庆县| 罗源县| 建水县| 尚志市| 富锦市| 襄城县| 宜兰县| 牡丹江市| 五河县| 上高县| 招远市| 枣庄市| 寿阳县| 西贡区| 理塘县| 民县| 绥棱县| 谷城县| 且末县| 略阳县| 兴义市| 卫辉市| 驻马店市|