PHP產生圖形驗證碼(大小寫字母與數字混合)

來源:互聯網
上載者:User
  1. header("content-type:image/png");
  2. $num = $_GET['num'];
  3. $imagewidth=60;
  4. $imageheight=18;
  5. srand(microtime() * 100000);
  6. $numimage = imagecreate($imagewidth,$imageheight);
  7. imagecolorallocate($numimage,183,180,83);
  8. for($i=0;$i $font = mt_rand(3,5);
  9. $x = mt_rand(1,8)+$imagewidth*$i/4;
  10. $y = mt_rand(1,$imageheight/3);
  11. $color=imagecolorallocate($numimage,mt_rand(0,50),mt_rand(0,150),mt_rand(0,255));
  12. imagestring($numimage,$font,$x,$y,$num[$i],$color);
  13. }
  14. imagepng($numimage);
  15. imagedestroy($numimage);
  16. ?>
  17. 調用方法:
  18. session_start();
  19. include_once 'conn/conn.php';
  20. $pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
  21. $num = null;
  22. for($i = 0; $i < 4; $i++) {
  23. $num .= $pattern{mt_rand(0, 61)};
  24. }
  25. ?>
  26. 驗證碼:
  27. " width="55" height="18" />
複製代碼
驗證碼, 寫字母, PHP
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.