欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用PHP繪圖函數(shù)實現(xiàn)簡單驗證碼功能的方法

 更新時間:2016年10月18日 09:00:13   投稿:jingxian  
下面小編就為大家?guī)硪黄肞HP繪圖函數(shù)實現(xiàn)簡單驗證碼功能的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

index.php

<?php
//===================================》》使用繪圖技術繪制驗證碼

//1.隨機產(chǎn)生4個隨機數(shù)
$checkCode="";
for ($i=0;$i<4;$i++){
$checkCode.=dechex(rand(1, 15));// decheck()十進制轉(zhuǎn)換為十六進制,即驗證碼上要顯示的數(shù)字
}

//2.存入列
session_start();
$_SESSION['checkCode']=$checkCode;

//3.創(chuàng)建畫布
$image1=imagecreatetruecolor(100, 30);

//制造干擾,創(chuàng)建20條弧線
for ($j=0;$j<30;$j++){
imagearc($image1, rand(0, 100), rand(0, 30), rand(0, 100), rand(0, 30), rand(0, 360), rand(0, 360), imagecolorallocate($image1, rand(0, 155), rand(0, 255), rand(0, 255)));
}

//3.創(chuàng)建字體顏色,將字粘貼上去
$white=imagecolorallocate($image1, 255, 255, 255);
imagestring($image1, rand(2, 5), rand(5, 70), rand(2, 15), $checkCode, $white);

//5.輸出圖像或保存
header("content-type:image/png");
imagepng($image1);

//6.釋放資源
imagedestroy($image1);

login.php

請輸入驗證碼:<img src="index.php" onclick="this.src='index.php?a=+random()'">

以上就是小編為大家?guī)淼睦肞HP繪圖函數(shù)實現(xiàn)簡單驗證碼功能的方法全部內(nèi)容了,希望大家多多支持腳本之家~

相關文章

最新評論