国产探花免费观看_亚洲丰满少妇自慰呻吟_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編碼
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 禄丰县| 天镇县| 安庆市| 五常市| 山东省| 阳朔县| 高州市| 石家庄市| 兴宁市| 海兴县| 庐江县| 申扎县| 马边| 朝阳市| 中西区| 南宁市| 湖南省| 中江县| 陆河县| 长春市| 商城县| 华亭县| 仲巴县| 雷州市| 陇西县| 原阳县| 无为县| 句容市| 张家港市| 太湖县| 江都市| 交口县| 梨树县| 密云县| 时尚| 木兰县| 潍坊市| 无锡市| 奉化市| 锦屏县| 喀喇|