簡單的驗證碼產生,簡單驗證碼產生_PHP教程

來源:互聯網
上載者:User

簡單的驗證碼產生,簡單驗證碼產生


for($i=0;$i<5;$i++){

$rand .= dechex(rand(1,15)); // 隨機數16進位 1-F 產生5個

}

$im = imagecreatetruecolor(100,30); // 驗證碼的大小(畫板)

$bg = imagecolorallocate($im, 0,0,0); // 背景顏色

for($i<0;$i<100;$i++){

$color_dian = imagecolorallocate($im, rand(0,255),rand(0,255),rand(0,255));

imagesetpixel($im, rand()%100, rand()%30, $color_dian); // 在畫板上畫點

}

$color_font = imagecolorallocate($im, rand(88,255), rand(88,255), rand(100,255)); // 設定顏色 文字的顏色

$color_line = imagecolorallocate($im, rand(0,255),rand(0,255),rand(0,255)); // 設定顏色 線的顏色

imageline($im, rand(1,10), rand(5,13), rand(80,100), rand(5,15), $color_line); // 線 從第二個參數開始 線頭的x軸 、y軸 、結束的x軸 、y軸、 賦予的顏色

imagestring($im,5,rand(4,60), rand(3,10), $rand ,$color_font); // 在畫板上 寫入 產生的碼 從第二個參數開始 字型的屬性、顯示在畫板上的位置x軸、y軸、隨機驗證碼、顏色

// imagettftext($im, 12, 0, 12, 20, $color_font, 'haha.ttf', "我狠"); 在畫板上寫字

header("Content-type:image/jpeg"); // 聲明要輸出的是什麼東西

imagejpeg($im); // 以jpeg格式輸出圖片到瀏覽器

http://www.bkjia.com/PHPjc/1130671.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1130671.htmlTechArticle簡單的驗證碼產生,簡單驗證碼產生 for($i= 0;$i 5;$i++){ $rand .= dechex( rand( 1, 15)); // 隨機數16進位 1-F 產生5個 } $im = imagecreatetruecolor ( 100 , 30 )...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.