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

首頁 > 開發(fā) > PHP > 正文

php生成數(shù)字字母的驗(yàn)證碼圖片

2024-05-04 23:37:47
字體:
供稿:網(wǎng)友

本文給大家分享的是使用php實(shí)現(xiàn)的生成包含數(shù)字字母的驗(yàn)證碼圖片的代碼,十分的簡單實(shí)用,有需要的小伙伴可以參考下

php生成數(shù)字字母的驗(yàn)證碼圖片

 

 
  1. <?php 
  2.  
  3. header ('Content-Type: image/png'); 
  4. $image=imagecreatetruecolor(100, 30); 
  5. $color=imagecolorallocate($image, 255, 255, 255); 
  6. imagefill($image, 20, 20, $color); 
  7. //只含有數(shù)字 
  8. // for($i=0;$i<4;$i++){ 
  9. // $font=6; 
  10. // $x=rand(5,10)+$i*100/4; 
  11. // $y=rand(8, 15); 
  12. // $string=rand(0, 9); 
  13. // $color=imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120)); 
  14. // imagestring($image, $font, $x, $y, $string, $color); 
  15. // } 
  16.  
  17. //含有數(shù)字和字母的 
  18. for($i=0;$i<4;$i++){ 
  19. $fontSize=6; 
  20. $x=rand(5,10)+$i*100/4; 
  21. $y=rand(5, 15); 
  22. $data='abcdefghijklmnopqrstuvwxyz123456789'
  23. $string=substr($data,rand(0, strlen($data)),1); 
  24. $color=imagecolorallocate($image,rand(0,120), rand(0,120), rand(0,120)); 
  25. imagestring($image, $fontSize, $x, $y, $string, $color); 
  26. //干擾點(diǎn)元素 
  27. for($i=0;$i<200;$i++){ 
  28. $pointColor=imagecolorallocate($image, rand(100, 255), rand(100, 255), rand(100, 255)); 
  29. imagesetpixel($image, rand(0, 100), rand(0, 30), $pointColor); 
  30. //干擾線元素 
  31. for($i=0;$i<2;$i++){ 
  32. $linePoint=imagecolorallocate($image, rand(150, 255), rand(150, 255), rand(150, 255)); 
  33. imageline($image, rand(10, 50), rand(10, 20), rand(80,90), rand(15, 25), $linePoint); 
  34. imagepng($image); 
  35. imagedestroy($image); 
  36. ?> 

以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 洮南市| 天门市| 青川县| 台南市| 丰原市| 双柏县| 紫阳县| 陕西省| 新兴县| 巴塘县| 青神县| 邛崃市| 碌曲县| 南岸区| 侯马市| 沙田区| 长沙县| 酉阳| 东阿县| 乌恰县| 五莲县| 迭部县| 安塞县| 凤凰县| 蕉岭县| 江门市| 平湖市| 肇东市| 额尔古纳市| 沧州市| 民和| 鄢陵县| 绵阳市| 邹平县| 肥乡县| 济宁市| 彰化县| 同心县| 长阳| 乐东| 金沙县|