中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php生成驗證碼 支持中文 字母 數(shù)字混合

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
<?php
 //驗證碼的制作
 //1.生成4位的隨機數(shù)
 for($i=0;$i<4;$i++){
     $rand.=dechex(rand(1, 15));
 }
  
 //2.創(chuàng)建圖片
 //創(chuàng)建一張圖片
 $image=imagecreatetruecolor(100, 30);
 //背景顏色
 $bg=imagecolorallocate($image, 0, 0, 0);
 $te=imagecolorallocate($image, 255,255,255);
  
  
 //劃線
 for($i=0;$i<4;$i++){
     $lineColor=imagecolorallocate($image, rand(20, 225), rand(20, 225), rand(20, 225));
     imageline($image, rand(0, 100), 0, 100,30, $lineColor);
 }
 //劃點
 for($i=0;$i<200;$i++){
     imagesetpixel($image, rand()%100, rand()%100, $lineColor);
 }
 //添加文字
 //編碼轉(zhuǎn)換
 $str=iconv("GBK", "UTF-8", "廣州GZ");
 imagettftext($image, 12,11, 20, 20, $lineColor, 'simhei.ttf', $str);
  
 //3.隨機數(shù)寫入圖片$font=(1~6)
 imagestring($image, rand(3, 6), rand(3, 70), rand(0, 16), $rand, $te);
  
 //4.隨機數(shù)保存在session中
 //啟動session
 session_start();
 //把驗證碼放入session
 $_SESSION[vilidationCode]=$rand;
  
  
 header("Content-type: image/jpeg");
 imagejpeg($image);
 ?>

標簽:

版權(quán)申明:本站文章部分自網(wǎng)絡,如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:OpenCV圖像匹配算法之brisk

下一篇:過濾XSS攻擊的PHP函數(shù)